Skip to content
Brooks Patton edited this page Jun 12, 2018 · 1 revision

Hash Map

Methods that are useful

entry

Entry is used to get a mutable reference to a value in the hashmap. It returns as an Option Some / Option None.

documentation

  let mut d = departments.entry(department);
  d.push(name);

.or_insert

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.

documentation

  let mut d = departments.entry(department).or_insert(vec![]);
  d.push(name);
Clone this wiki locally