Skip to content

Commit 077ca79

Browse files
committedJun 2, 2013
auto merge of #6867 : Dretch/rust/hashmap_get_mut, r=nikomatsakis
2 parents c354a0c + d443fc6 commit 077ca79

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
 

‎src/libstd/hashmap.rs

+9
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,15 @@ impl<K: Hash + Eq, V> HashMap<K, V> {
501501
}
502502
}
503503

504+
/// Retrieves a (mutable) value for the given key, failing if the key
505+
/// is not present.
506+
pub fn get_mut<'a>(&'a mut self, k: &K) -> &'a mut V {
507+
match self.find_mut(k) {
508+
Some(v) => v,
509+
None => fail!("No entry found for key: %?", k),
510+
}
511+
}
512+
504513
/// Return true if the map contains a value for the specified key,
505514
/// using equivalence
506515
pub fn contains_key_equiv<Q:Hash + Equiv<K>>(&self, key: &Q) -> bool {

0 commit comments

Comments
 (0)
Please sign in to comment.