Skip to content

Instantly share code, notes, and snippets.

@marti1125
Created April 27, 2017 00:45
Show Gist options
  • Save marti1125/7ffda8adebc55061ab417113287d8043 to your computer and use it in GitHub Desktop.
Save marti1125/7ffda8adebc55061ab417113287d8043 to your computer and use it in GitHub Desktop.
Rust Match
fn main() {
// Match
let x = 5;
match x {
1 => println!("one"),
2 => println!("two"),
3 => println!("three"),
4 => println!("four"),
5 => println!("five"),
_ => println!("something else"),
}
// Match Patterns
let a = 1;
match a {
1 | 2 => println!("one or two"),
3 => println!("three"),
_ => println!("anything"),
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment