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
This commit is contained in:
commit
46504e9a9d
@ -1654,6 +1654,15 @@ impl<'a, K: Ord, 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: Ord, V> VacantEntry<'a, K, V> {
|
||||
|
@ -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> {
|
||||
|
Loading…
Reference in New Issue
Block a user