From d443fc6d90577003724ce128d2c07b7ad6b347c9 Mon Sep 17 00:00:00 2001
From: gareth <gareth@gareth-N56VM.(none)>
Date: Fri, 31 May 2013 20:56:05 +0100
Subject: [PATCH] Add a get_mut method to accompany the get method.

---
 src/libstd/hashmap.rs | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/libstd/hashmap.rs b/src/libstd/hashmap.rs
index fb4cab72126..b1400d1bc76 100644
--- a/src/libstd/hashmap.rs
+++ b/src/libstd/hashmap.rs
@@ -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 {