SHARE
TWEET

Untitled

a guest Dec 13th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top