mirror of https://github.com/rust-lang/book
25 lines
378 B
Rust
25 lines
378 B
Rust
#[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;
|
|
match coin {
|
|
Coin::Quarter(state) => println!("State quarter from {state:?}!"),
|
|
_ => count += 1,
|
|
}
|
|
// ANCHOR_END: here
|
|
}
|