1
try!
と?
マクロで私は極端な困難を抱えています。私はstraight from the rust-docsの下の例を持ち上げ、それはまだ私の顔に爆破する。疑問符の付いた標準文書の例はコンパイルされません
コード:
pub use std::fs::File;
pub use std::io::prelude::*;
fn main() {
let mut file: File = File::open("foo.txt")?;
file.write_all(b"Hello, world!")?;
}
がエラー:
error[E0277]: the trait bound `(): std::ops::Try` is not satisfied
--> src/main.rs:6:23
|
6 | let mut file: File = File::open("foo.txt")?;
| ----------------------
| |
| the trait `std::ops::Try` is not implemented for `()`
| in this macro invocation
|
= note: required by `std::ops::Try::from_error`
error[E0277]: the trait bound `(): std::ops::Try` is not satisfied
--> src/main.rs:7:2
|
7 | file.write_all(b"Hello, world!")?;
| ---------------------------------
| |
| the trait `std::ops::Try` is not implemented for `()`
| in this macro invocation
|
= note: required by `std::ops::Try::from_error`
私はrustup
による錆の最新の安定版リリース(1.19.0)