std-method
BTreeSet::pop_last
Remove and own the largest item in an ordered set. The result is None if the set is empty. Expected stdout (not executed): Some(7) Some(3) Common mistake: Expecting removal of the last inserted element.
Formal Syntax & Structure
rust syntaxrust
fn pop_last(&mut self) -> Option<T>Working Example
Example Snippetrust
fn main() { use std::collections::BTreeSet; let mut ids = BTreeSet::from([3, 7, 2]); println!("{:?}", ids.pop_last()); println!("{:?}", ids.last());}