Skip to content

Commit 1068f94

Browse files
authored
Rollup merge of rust-lang#80022 - ssomers:btree_cleanup_8, r=Mark-Simulacrum
BTreeSet: simplify implementation of pop_first/pop_last …and stop it interfering in rust-lang#79245. r? ```@Mark-Simulacrum```
2 parents 68b75db + 6c7835e commit 1068f94

File tree

1 file changed

+2
-2
lines changed
  • library/alloc/src/collections/btree

1 file changed

+2
-2
lines changed

library/alloc/src/collections/btree/set.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ impl<T: Ord> BTreeSet<T> {
679679
/// ```
680680
#[unstable(feature = "map_first_last", issue = "62924")]
681681
pub fn pop_first(&mut self) -> Option<T> {
682-
self.map.first_entry().map(|entry| entry.remove_entry().0)
682+
self.map.pop_first().map(|kv| kv.0)
683683
}
684684

685685
/// Removes the last value from the set and returns it, if any.
@@ -701,7 +701,7 @@ impl<T: Ord> BTreeSet<T> {
701701
/// ```
702702
#[unstable(feature = "map_first_last", issue = "62924")]
703703
pub fn pop_last(&mut self) -> Option<T> {
704-
self.map.last_entry().map(|entry| entry.remove_entry().0)
704+
self.map.pop_last().map(|kv| kv.0)
705705
}
706706

707707
/// Adds a value to the set.

0 commit comments

Comments
 (0)