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