Guest User

Untitled

a guest
Dec 13th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. //example for Ok and Err
  2.  
  3. use std::fs::File;
  4.  
  5. fn main() {
  6. let f = File::open("hello.txt");
  7.  
  8. let f = match f {
  9. Ok(file) => file,
  10. Err(error) => {
  11. panic!("There was a problem opening the file: {:?}", error) // as there’s no file named hello.txt and if we run this code, we’ll see the following error thread 'main' panicked at 'There was a problem opening the file
  12. },
  13. };
  14. }
Add Comment
Please, Sign In to add comment