Created
August 22, 2019 08:16
-
-
Save rust-play/0369b0abc6a48c0da86175cb56451178 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Debug, Clone, Copy)] | |
enum Foo { | |
A, | |
B, | |
C | |
} | |
fn main() { | |
let x = Foo::A; | |
match x { | |
Foo::A => println!("A"), | |
_ => println!("not A"), | |
} | |
match x { | |
A => println!("this is just a variable called 'A', {:?}", A), | |
Asdf => println!("also just a variable, but the 'A' branch will match before this"), | |
} | |
{ | |
use Foo::*; | |
match x { | |
B => println!("the enum variants are in scope here"), | |
A => println!("so this second arm will match"), | |
C => println!("C") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment