]>
Commit | Line | Data |
---|---|---|
74b04a01 XL |
1 | $ cargo run |
2 | Compiling error-handling v0.1.0 (file:///projects/error-handling) | |
94222f64 XL |
3 | error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) |
4 | --> src/main.rs:4:36 | |
74b04a01 XL |
5 | | |
6 | 3 | / fn main() { | |
7 | 4 | | let f = File::open("hello.txt")?; | |
94222f64 | 8 | | | ^ cannot use the `?` operator in a function that returns `()` |
74b04a01 XL |
9 | 5 | | } |
10 | | |_- this function should return `Result` or `Option` to accept `?` | |
11 | | | |
94222f64 XL |
12 | = help: the trait `FromResidual<Result<Infallible, std::io::Error>>` is not implemented for `()` |
13 | = note: required by `from_residual` | |
74b04a01 XL |
14 | |
15 | error: aborting due to previous error | |
16 | ||
17 | For more information about this error, try `rustc --explain E0277`. | |
fc512014 | 18 | error: could not compile `error-handling` |
74b04a01 XL |
19 | |
20 | To learn more, run the command again with --verbose. |