You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
446 B
28 lines
446 B
1 year ago
|
enum Foo {
|
||
|
Bar,
|
||
|
Baz,
|
||
|
Qux(u32),
|
||
|
}
|
||
|
|
||
|
fn main() {
|
||
|
let a = Foo::Bar;
|
||
|
let b = Foo::Baz;
|
||
|
let c = Foo::Qux(100);
|
||
|
|
||
|
if let Foo::Bar = a {
|
||
|
println!("a is a foobar");
|
||
|
}
|
||
|
|
||
|
if let Foo::Bar = b {
|
||
|
println!("b is foobar");
|
||
|
}
|
||
|
|
||
|
if let Foo::Qux(value) = c {
|
||
|
println!("c is {}", value);
|
||
|
}
|
||
|
|
||
|
if let Foo::Qux(value @ 100) = c {
|
||
|
println!("c is one hundred (value: {:?})", value);
|
||
|
}
|
||
|
}
|