Created
March 5, 2021 11:36
-
-
Save madmag77/af9f8017d44568013aa9afbd1f8cf1a0 to your computer and use it in GitHub Desktop.
[Dart article] Rust exception example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fs::File; | |
fn main() { | |
let f = File::open("main.jpg"); // main.jpg doesn't exist | |
match f { | |
Ok(f)=> { | |
println!("file found {:?}",f); | |
}, | |
Err(e)=> { | |
println!("file not found \n{:?}",e); //handled error | |
} | |
} | |
println!("end of main"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment