std-method

BTreeMap::pop_last

Remove the greatest-key record. It can implement descending priority processing if each key uniquely identifies a job. Expected stdout (not executed): Some((7, "urgent")) Common mistake: Using a bare priority as key when multiple jobs can share it.

Formal Syntax & Structure

rust syntaxrust
fn pop_last(&mut self) -> Option<(K, V)>

Working Example

Example Snippetrust
fn main() {    use std::collections::BTreeMap;    let mut jobs = BTreeMap::from([(2, "later"), (7, "urgent")]);    println!("{:?}", jobs.pop_last());}
Rust Reference