diff --git a/src/main.rs b/src/main.rs index 48e388a..57c5f73 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,7 +22,8 @@ fn main() { let x = x + 1; println!("The value of x is {}", x); - let x = "test"; + // let x = "test"; + let x: &'static str = "test"; println!("The value of x is {}", x); // 可变变量 @@ -1084,6 +1085,15 @@ impl Point1 { fn mixup(self, p: Point1) -> Point1 { Point1 { x: self.x, y: p.y } } + + + let nms = vec![String::from("Blue"), String::from("Yellow")]; + let x4 = &[String::from("Blue"), String::from("Yellow")]; + println!("{:?} {:?}", nms, x4); + + // let a = [1, 2, 3, 4, 5]; + + let slice = &[1,2]; } fn test_tuple(t: (i32, &str)) {