So I am reading through The Rust Programming Language book. Specifically, in this section it says the code
scores.entry(String::from("Blue")).or_insert(50);
"returns a mutable reference to the value", so my assumption is that I can do this:
let &mut reff = scores.entry(String::from("Blue")).or_insert(50);
*reff += 1;
Since &mut
is supposed to be a mutable reference. However, when I do that I get this error:
error[E0614]: type `{integer}` cannot be dereferenced
--> src/main.rs:9:5
|
9 | *reff += 1;
| ^^^^^
Anyone know why?
Interestingly if I just do:
let reff = scores.entry(String::from("Blue")).or_insert(50);
*reff += 1;
It works.