What in the Maps going on?
Can someone please explain whats happening here ( coming from a Java background ) this examples directly from the book:
use std::collections::HashMap;
let text = "hello world wonderful world"
let mut map = HashMap::new();
for word in text.split_whitespace() {
let count = map.entry(word).or_insert(0);
*count +=1;
}
println!("{:?}, map);
Returns
{"world": 2, "hello": 1, "wonderful": 1};
How are the values being incremented by count?
As I can't see count being referenced when assigning the values to the map?
Is this due to borrowing?