文章目录
- match 分支
- 参考
match 分支
所有结果都得匹配到
// Match Expressionfn main() {#[derive(Debug)]enum Language {English,Spanish,Russian,Japanese,}let language = Language::English;match language {Language::English => println!("Hello World!"),Language::Spanish => println!("Hola Mundo!"),Language::Russian => println!("npuBeT, Mnp!"),//_=> println!("Unsupported language!"),lang => println!("Unsupported language! {:?}", lang),}
}
参考
- 第18章~模式和匹配