|
|
|
|
|
by almatabata
842 days ago
|
|
It will compile just fine if you call unwrap on a Result and then you get a wonderful error. If you call unwrap on a File::open() you do not even get the file name. If you run this use std::fs::File;
pub fn main() {
let fp = File::open("test").unwrap();
} You get this: thread 'main' panicked at /app/example.rs:11:33:
called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace The language incentives you to propagate errors up to main and then just let it fail. |
|