一、Vector
fn main() {
//let mut v= Vec::new();
let mut v = vec![1,2,3];
v.push(4);
let third: &i32 = &v[2];
println!("the third value is {}",third)
}
因为first是不可变的,所以就报错了;因为vector数据在内存中是连续的
fn main() {
//let mut v= Vec::new();
let mut v = vec![1,2,3];
v.push(4);
let third: &i32 = &v[2];
println!("the third value is {}",third);
// for循环遍历vector
let mut newVector = vec![100,32,88];
for eachData in &mut newVector {
*eachData +=50;
println!("{}",eachData);
}
}
enum包装不同类型数据,再放到vector下面