-1
なぜこの錆コードはコンパイルされませんか?試してみてください!一致しない型をコンパイルしません
docsのコードとよく似ています。
コンパイルエラー:あなたは、ループ内の各ディレクトリエントリのための新たな結合をしたいよう
<std macros>:3:43: 3:46 error: mismatched types:
expected `core::result::Result<std::fs::DirEntry, std::io::error::Error>`,
found `std::fs::DirEntry`
(expected enum `core::result::Result`,
found struct `std::fs::DirEntry`) [E0308]
<std macros>:3 $ crate:: result:: Result:: Ok (val) => val , $ crate:: result:: Result::
^~~
src/main.rs:13:17: 13:28 note: in this expansion of try! (defined in <std macros>)
<std macros>:3:43: 3:46 help: run `rustc --explain E0308` to see a detailed explanation
src/main.rs:12:5: 14:6 error: mismatched types:
expected `core::result::Result<(), std::io::error::Error>`,
found `()`
(expected enum `core::result::Result`,
found()) [E0308]
src/main.rs:12 for entry in try!(fs::read_dir(path)) {
src/main.rs:13 entry = try!(entry);
src/main.rs:14 }
src/main.rs:12:5: 14:6 help: run `rustc --explain E0308` to see a detailed explanation
は同じことを行うドキュメントの例ではありませんか? –
@VictorAurélio - 'entry'の前に' let'がありません。 – Lee
私は 'let'を追加しましたが、まだエラーがあります(2番目のエラーのみ)。 –