Mutability

If you mark a variable as mut that contains other nested structures, all of the structures become mutable. For example, if you mark a vec containing some vecs as mutable, all the contained vecs as well the containing vec become mutable.

let mut x = vec![
  vec![1, 2, 3],
  vec![4, 5, 6]
]

// mutate outside vec by entirely replacing an entry
x[0] = vec![7, 8, 9]; // => [[7, 8, 9], [4, 5, 6]]

// mutate an inner vec by changing an entry

x[1][2] = 1; // [[7, 8, 9], [4, 5, 1]]