|
// Since the `?` operator returns an `Err` early if the thing it's trying to |
|
// do fails, you can only use the `?` operator in functions that have a |
|
// `Result` as their return type. |
|
|
|
// Hence the error that you get if you run this code is: |
|
|
|
// ``` |
|
// error[E0277]: the `?` operator can only be used in a function that returns `Result` (or another type that implements `std::ops::Try`) |
|
// ``` |
|
|
|
// So we have to use another way of handling a `Result` within `main`. |
Since rust 1.26 main can also return Result.
rustlings/exercises/error_handling/errors3.rs
Lines 48 to 58 in 5e1d7c3
Since rust 1.26
maincan also return Result.