rust(72)-match匹配
生活随笔
收集整理的這篇文章主要介紹了
rust(72)-match匹配
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
fn main() {for n in 2..101{let num1=n % 2;let num2=n % 7;match num1 {0=>println!("{:?} 偶數",n),1=>println!("{:?} 奇數",n),_ =>println!("{:?} other",n),} match num2 {1...3 =>println!("{:?} 1-3",n),5|6 =>println!("{:?} 5-6",n),_ =>println!("{:?} other",n),}}
}
2 偶數
2 1-3
3 奇數
3 1-3
4 偶數
4 other
5 奇數
5 5-6
6 偶數
6 5-6
...
99 奇數
99 1-3
100 偶數
100 1-3
總結
以上是生活随笔為你收集整理的rust(72)-match匹配的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: rust(71)-for、while循环
- 下一篇: Mybatis源码分析之(六)mybat