mirror of https://github.com/KaiserY/trpl-zh-cn
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.
26 lines
388 B
26 lines
388 B
3 years ago
|
#[derive(Debug)]
|
||
|
enum UsState {
|
||
|
Alabama,
|
||
|
Alaska,
|
||
|
// --snip--
|
||
|
}
|
||
|
|
||
|
enum Coin {
|
||
|
Penny,
|
||
|
Nickel,
|
||
|
Dime,
|
||
|
Quarter(UsState),
|
||
|
}
|
||
|
|
||
|
fn main() {
|
||
|
let coin = Coin::Penny;
|
||
|
// ANCHOR: here
|
||
|
let mut count = 0;
|
||
|
if let Coin::Quarter(state) = coin {
|
||
|
println!("State quarter from {:?}!", state);
|
||
|
} else {
|
||
|
count += 1;
|
||
|
}
|
||
|
// ANCHOR_END: here
|
||
|
}
|