Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BTreeSet: simplify implementation of pop_first/pop_last #80022

Merged
merged 1 commit into from
Dec 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions library/alloc/src/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ impl<T: Ord> BTreeSet<T> {
/// ```
#[unstable(feature = "map_first_last", issue = "62924")]
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.
Expand All @@ -701,7 +701,7 @@ impl<T: Ord> BTreeSet<T> {
/// ```
#[unstable(feature = "map_first_last", issue = "62924")]
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.
Expand Down