//1、字符串slice是String中一部分值的引用//2、字面值就是slice//3、其它类型slicefnmain(){let s =String::from("hello world");let h =&s[0..5];//区间[0,5)let h =&s[0..=4];//区间[0,4]let h =&s[..=4];//区间[0,4]let h =&s[..5];//区间[0,5)println!("h = {}", h);let w =&s[6..11];//区间[6,11)let w =&s[6..=10];//区间[6,10]let w =&s[6..];//区间[6,s.len())let w =&s[..];//区间[0,s.len())println!("w = {}", w);//let ss = String::from("你好");//let w1 = &ss[0..1];let a =[1,2,3,4];let sss =&a[1..3];//取a中[1,3)的元素println!("sss = {}", sss[0]);//a[1]println!("sss = {}", sss[1]);//a[2]println!("len = {}", sss.len());//长度为2}