diff options
| author | bors <bors@rust-lang.org> | 2016-04-29 18:11:25 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-04-29 18:11:25 -0700 |
| commit | 46504e9a9d3a57a852ff57f7530de2017a7b37ba (patch) | |
| tree | 491b366d8000acd3527ae56d91ef4539b25ea0e6 /src/libstd | |
| parent | 9b63263d0d2ee265765ba7f802d2b23fe5d413f5 (diff) | |
| parent | 9e167ef60ac6201971867a74a6d00628fd7a0106 (diff) | |
| download | rust-46504e9a9d3a57a852ff57f7530de2017a7b37ba.tar.gz rust-46504e9a9d3a57a852ff57f7530de2017a7b37ba.zip | |
Auto merge of #33148 - sfackler:entry-key, r=alexcrichton
Add Entry::key This method was present on both variants of Entry, but not the enum cc #32281 r? @alexcrichton
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 70b3edac5c5..abb33b33f3f 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> { |
