trpl-zh-cn/listings/ch06-enums-and-pattern-matching/no-listing-01-defining-enums/src/main.rs
2022-02-06 16:43:51 +08:00

23 lines
369 B
Rust
Executable File

// ANCHOR: def
enum IpAddrKind {
V4,
V6,
}
// ANCHOR_END: def
fn main() {
// ANCHOR: instance
let four = IpAddrKind::V4;
let six = IpAddrKind::V6;
// ANCHOR_END: instance
// ANCHOR: fn_call
route(IpAddrKind::V4);
route(IpAddrKind::V6);
// ANCHOR_END: fn_call
}
// ANCHOR: fn
fn route(ip_kind: IpAddrKind) {}
// ANCHOR_END: fn