fn main() { struct Item { id: i32, weight: f32 } let mut items: Vec = Vec::new(); items.push(Item { id: 1, weight: 0.5 }); let first = 0; // retain an index, not a reference across push for i in 2..1_000_001 { items.push(Item { id: i, weight: 0.0 }); } items[first].weight = 99.5; println!("{} items, first is Item {{ {}, {} }}", items.len(), items[0].id, items[0].weight); assert_eq!(items[first].weight,99.5); }