Skip to content

Commit 46504e9

Browse files
committed
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
2 parents 9b63263 + 9e167ef commit 46504e9

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/libcollections/btree/map.rs

+9
Original file line numberDiff line numberDiff line change
@@ -1654,6 +1654,15 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
16541654
Vacant(entry) => entry.insert(default()),
16551655
}
16561656
}
1657+
1658+
/// Returns a reference to this entry's key.
1659+
#[unstable(feature = "map_entry_keys", issue = "32281")]
1660+
pub fn key(&self) -> &K {
1661+
match *self {
1662+
Occupied(ref entry) => entry.key(),
1663+
Vacant(ref entry) => entry.key(),
1664+
}
1665+
}
16571666
}
16581667

16591668
impl<'a, K: Ord, V> VacantEntry<'a, K, V> {

src/libstd/collections/hash/map.rs

+9
Original file line numberDiff line numberDiff line change
@@ -1533,6 +1533,15 @@ impl<'a, K, V> Entry<'a, K, V> {
15331533
Vacant(entry) => entry.insert(default()),
15341534
}
15351535
}
1536+
1537+
/// Returns a reference to this entry's key.
1538+
#[unstable(feature = "map_entry_keys", issue = "32281")]
1539+
pub fn key(&self) -> &K {
1540+
match *self {
1541+
Occupied(ref entry) => entry.key(),
1542+
Vacant(ref entry) => entry.key(),
1543+
}
1544+
}
15361545
}
15371546

15381547
impl<'a, K, V> OccupiedEntry<'a, K, V> {

0 commit comments

Comments
 (0)