Rust 程序设计语言 简体中文版 1.85.0`target/debug/error-handling` thread 'main' panicked at src/main.rs:8:23: Problem opening the file: Os { code: 2, kind: NotFound, message: "No such file or directory" } note: run with `RUST_BACKTRACE=1` environment 调用 panic! 时提供的 错误信息: thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/main.rs:4:49 同样,expect 方法也允许我们自定义 息。它看起来像这样: thread 'main' panicked at src/main.rs:5:10: hello.txt should be included in this project: Os { code: 2, kind: NotFound, message: "No such file or directory" } 在生产级别的代码中,大部分 Rustaceans 选择 expect 而不是0 码力 | 562 页 | 3.23 MB | 21 天前3
共 1 条
- 1













