Closed
Description
The following code works fine in cpp:
std::map<int, int> m;
m[0] = 0;
In Rust however, you are getting an error:
let mut f :HashMap<u8, u8> = HashMap::new();
f[&0] = 0;
error[E0594]: cannot assign to immutable indexed content
--> src/main.rs:4:2
|
4 | f[&0] = 0;
| ^^^^^^^^^ cannot borrow as mutable
The error doesn't really tell you what is indexed immutably. IMO it should explain that hashmaps have the insert function instead and maybe even should suggest it.