Advertisement
cwchen

[Rust] Enum demo with match.

Aug 23rd, 2017
575
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.33 KB | None | 0 0
  1. enum Day {
  2.     Sunday,
  3.     Monday,
  4.     Tuesday,
  5.     Wednesday,
  6.     Thursday,
  7.     Friday,
  8.     Saturday,
  9. }
  10.  
  11. fn main() {
  12.     let day = Day::Sunday;
  13.  
  14.     match day {
  15.         Day::Saturday | Day::Sunday => {
  16.             println!("Relax yourself");
  17.         }
  18.         _ => {
  19.             println!("Work hardly")
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement