mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2025-02-24 21:32:15 +08:00
26 lines
388 B
Rust
Executable File
26 lines
388 B
Rust
Executable File
#[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
|
|
}
|