Hello
I'm reading this book
and I don' get something.
fn main() { let weather_vec = vec![ vec!["Berlin", "cloudy", "5", "-7", "78"], vec!["Athens", "sunny", "not humid", "20", "10", "50"], ]; for mut city in weather_vec { println!("For the city of {}:", city[0]); // In our data, every first item is the city name while let Some(information) = city.pop() { // This means: keep going until you can't pop anymore // When the vector reaches 0 items, it will return None // and it will stop. if let Ok(number) = information.parse::<i32>() { // Try to parse the variable we called information // This returns a result. If it's Ok(number), it will print it println!("The number is: {}", number); } // We don't write anything here because we do nothing if we get an error. Throw them all away } } }
Why it is possible to pop items from inner vectors even though they are define as immutable? I also see this
for mut city in weather_vec
but still can't understand why.
Thank you for your help and as always sorry for my english.
Best regards.