- iter_mut
Mutable iterator
examples/iterators/change/src/main.rs
fn main() { let mut numbers = [2, 3, 4]; println!("{numbers:?}"); for num in numbers.iter_mut() { *num += 1; } println!("{numbers:?}"); }
[2, 3, 4] [3, 4, 5]
fn main() { let mut numbers = [2, 3, 4]; println!("{numbers:?}"); for num in numbers.iter_mut() { *num += 1; } println!("{numbers:?}"); }
[2, 3, 4] [3, 4, 5]