Skip to content

Commit

Permalink
Add a get_mut method to accompany the get method.
Browse files Browse the repository at this point in the history
  • Loading branch information
gareth authored and gareth committed Jun 2, 2013
1 parent c354a0c commit d443fc6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/libstd/hashmap.rs
Expand Up @@ -501,6 +501,15 @@ impl<K: Hash + Eq, V> HashMap<K, V> {
}
}

/// Retrieves a (mutable) value for the given key, failing if the key
/// is not present.
pub fn get_mut<'a>(&'a mut self, k: &K) -> &'a mut V {
match self.find_mut(k) {
Some(v) => v,
None => fail!("No entry found for key: %?", k),
}
}

/// Return true if the map contains a value for the specified key,
/// using equivalence
pub fn contains_key_equiv<Q:Hash + Equiv<K>>(&self, key: &Q) -> bool {
Expand Down

5 comments on commit d443fc6

@bors
Copy link
Contributor

@bors bors commented on d443fc6 Jun 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from nikomatsakis
at Dretch@d443fc6

@bors
Copy link
Contributor

@bors bors commented on d443fc6 Jun 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging Dretch/rust/hashmap_get_mut = d443fc6 into auto

@bors
Copy link
Contributor

@bors bors commented on d443fc6 Jun 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dretch/rust/hashmap_get_mut = d443fc6 merged ok, testing candidate = 077ca79

@bors
Copy link
Contributor

@bors bors commented on d443fc6 Jun 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on d443fc6 Jun 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = 077ca79

Please sign in to comment.