Skip to content

Instantly share code, notes, and snippets.

@RGGH
Created December 1, 2022 15:00
Show Gist options
  • Save RGGH/c25d09b556d89670e365d4910ded4663 to your computer and use it in GitHub Desktop.
Save RGGH/c25d09b556d89670e365d4910ded4663 to your computer and use it in GitHub Desktop.
Update a 2d array in Rust
fn main() {
let mut mar = [[1, 3, 5], [2, 4, 6], [7, 8, 9]];
for row in mar.iter_mut() {
for num in row.iter_mut() {
*num += 5;
print!("{:?} ", num)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment