Closed
Description
use std::collections::HashMap;
fn main() {
let x = HashMap::new();
x.insert("a", 3);
println!("{:?}", x.get("a"));
}
Produces
error[E0596]: cannot borrow immutable local variable `x` as mutable
--> src/main.rs:5:5
|
4 | let x = HashMap::new();
| - consider changing this to `mut x`
5 | x.insert("a", 3);
| ^ cannot borrow mutably
The suggestion for line 4 is a label, not a suggestion.