-
Notifications
You must be signed in to change notification settings - Fork 5
hash_maps
Brooks Patton edited this page Jun 12, 2018
·
1 revision
Entry is used to get a mutable reference to a value in the hashmap. It returns as an Option Some / Option None.
let mut d = departments.entry(department);
d.push(name);
Or insert is used to insert new data into the hashmap in the case that the entry used previously didn't find any data. It will be what is returned if there was no original key.
let mut d = departments.entry(department).or_insert(vec![]);
d.push(name);