标签:teacher code rust class get target match between splay
1 #![allow(unused)] 2 fn write_bar(size: u64){ 3 match size{ 4 o if o < 100 => println!("{:?} less than 100", o), 5 o if o < 200 && o > 100 => println!("{:?} between 100-200", o), 6 _ => println!("{:?} bigger than 200", size), 7 } 8 } 9 fn main() { 10 write_bar(10); 11 write_bar(150); 12 write_bar(250); 13 }
1 #[derive(Debug)] 2 struct Teacher<‘a> { 3 name: &‘a str, 4 age1: u8 5 } 6 7 #[derive(Debug)] 8 struct Person<‘a> { 9 name: &‘a str, 10 age: u8 11 } 12 13 fn main() { 14 let name = "Peter"; 15 let mut age = 27; 16 let peter = Person { name, age }; 17 18 age = 22; 19 let lilei = Teacher{ name:"Lilei", age1:age}; 20 // 美化打印 21 println!("{:#?}", lilei); 22 println!("{:#?}", peter); 23 }
标签:teacher code rust class get target match between splay
原文地址:https://www.cnblogs.com/shaohef/p/11273590.html