about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorSteven Fackler <sfackler@gmail.com>2016-04-21 22:19:49 -0700
committerSteven Fackler <sfackler@gmail.com>2016-04-21 22:19:49 -0700
commit9e167ef60ac6201971867a74a6d00628fd7a0106 (patch)
tree44d7a4d6d65b6272065ccd856347f9e89a914423 /src/libstd
parentb5ba5923f8a15f7f06c660442ad895aff15599c0 (diff)
downloadrust-9e167ef60ac6201971867a74a6d00628fd7a0106.tar.gz
rust-9e167ef60ac6201971867a74a6d00628fd7a0106.zip
Add Entry::key
This method was present on both variants of Entry, but not the enum

cc #32281
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/collections/hash/map.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs
index c20270e8306..4b5696b7913 100644
--- a/src/libstd/collections/hash/map.rs
+++ b/src/libstd/collections/hash/map.rs
@@ -1533,6 +1533,15 @@ impl<'a, K, V> Entry<'a, K, V> {
             Vacant(entry) => entry.insert(default()),
         }
     }
+
+    /// Returns a reference to this entry's key.
+    #[unstable(feature = "map_entry_keys", issue = "32281")]
+    pub fn key(&self) -> &K {
+        match *self {
+            Occupied(ref entry) => entry.key(),
+            Vacant(ref entry) => entry.key(),
+        }
+    }
 }
 
 impl<'a, K, V> OccupiedEntry<'a, K, V> {