Advertisement
cwchen

[Rust] match demo

Aug 22nd, 2017
622
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.31 KB | None | 0 0
  1. fn main() {
  2.     let grade = "A";
  3.  
  4.     match grade {
  5.         "A" => println!("Wonderful"),
  6.         "B" => println!("Good"),
  7.         "C" => println!("So so"),
  8.         "D" => println!("It could be better"),
  9.         "F" => println!("Oh, oh"),
  10.         _ => println!("Unknown grade"),  // Error on removal.
  11.     }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement