diff options
| author | Steven Fackler <sfackler@gmail.com> | 2016-04-21 22:19:49 -0700 |
|---|---|---|
| committer | Steven Fackler <sfackler@gmail.com> | 2016-04-21 22:19:49 -0700 |
| commit | 9e167ef60ac6201971867a74a6d00628fd7a0106 (patch) | |
| tree | 44d7a4d6d65b6272065ccd856347f9e89a914423 /src/libstd | |
| parent | b5ba5923f8a15f7f06c660442ad895aff15599c0 (diff) | |
| download | rust-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.rs | 9 |
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> { |
