BTreeSet: simplify implementation of pop_first/pop_last
This commit is contained in:
parent
7feab000b2
commit
6c7835e441
1 changed files with 2 additions and 2 deletions
|
@ -679,7 +679,7 @@ impl<T: Ord> BTreeSet<T> {
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "map_first_last", issue = "62924")]
|
#[unstable(feature = "map_first_last", issue = "62924")]
|
||||||
pub fn pop_first(&mut self) -> Option<T> {
|
pub fn pop_first(&mut self) -> Option<T> {
|
||||||
self.map.first_entry().map(|entry| entry.remove_entry().0)
|
self.map.pop_first().map(|kv| kv.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes the last value from the set and returns it, if any.
|
/// Removes the last value from the set and returns it, if any.
|
||||||
|
@ -701,7 +701,7 @@ impl<T: Ord> BTreeSet<T> {
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "map_first_last", issue = "62924")]
|
#[unstable(feature = "map_first_last", issue = "62924")]
|
||||||
pub fn pop_last(&mut self) -> Option<T> {
|
pub fn pop_last(&mut self) -> Option<T> {
|
||||||
self.map.last_entry().map(|entry| entry.remove_entry().0)
|
self.map.pop_last().map(|kv| kv.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a value to the set.
|
/// Adds a value to the set.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue