1 error[E0596]: cannot borrow data in an index of `HashMap<&str, String>` as mutable
2 --> $DIR/index-mut-help.rs:10:5
4 LL | map["peter"].clear();
5 | ^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable
7 = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `HashMap<&str, String>`
8 help: to modify a `HashMap<&str, String>` use `.get_mut()`
10 LL | map.get_mut("peter").map(|val| val.clear());
11 | ~~~~~~~~~ ~~~~~~~~~~~~~~~ +
13 error[E0594]: cannot assign to data in an index of `HashMap<&str, String>`
14 --> $DIR/index-mut-help.rs:11:5
16 LL | map["peter"] = "0".to_string();
17 | ^^^^^^^^^^^^ cannot assign
19 = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `HashMap<&str, String>`
20 help: to modify a `HashMap<&str, String>`, use `.get_mut()`, `.insert()` or the entry API
22 LL | map.insert("peter", "0".to_string());
24 LL | map.get_mut("peter").map(|val| { *val = "0".to_string(); });
25 | ~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ ++++
26 LL | let val = map.entry("peter").or_insert("0".to_string());
27 | +++++++++ ~~~~~~~ ~~~~~~~~~~~~ +
29 error[E0596]: cannot borrow data in an index of `HashMap<&str, String>` as mutable
30 --> $DIR/index-mut-help.rs:12:13
32 LL | let _ = &mut map["peter"];
33 | ^^^^^^^^^^^^^^^^^ cannot borrow as mutable
35 = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `HashMap<&str, String>`
36 = help: to modify a `HashMap<&str, String>`, use `.get_mut()`, `.insert()` or the entry API
38 error: aborting due to 3 previous errors
40 Some errors have detailed explanations: E0594, E0596.
41 For more information about an error, try `rustc --explain E0594`.