Trustport 2019-12-01
fn main() { //char支持4个字节,支持emoji let jp = "ゆ"; let emoji = "?"; let ch = "囧"; println!("jp is {}",jp); println!("ch is {}",ch); println!("emoji is {}",emoji); //元组,同python不可变 let tup:(i32,f64,u8) =(500,6.4,1); // 模式匹配解构 let (_,y,_) =tup; //支持元组解包 println!("the value of y is {}",y); //通过.加索引访问 let one = tup.0; println!("the value of one is {}",one); //静态类型语言的数组要求元素类型都相同 //数组是分配到栈上的内存 //i32是每个元素的类型,5是长度 let a:[i32;5] = [1,2,3,4,5]; //指定元素都相同的数组 //4表示数值,3表示个数 let b = [4; 3]; }