std-method
BTreeMap::last_key_value
Inspect the record with the greatest key while retaining the map. This does not search for the greatest value. Expected stdout (not executed): Some((5, 42)) Common mistake: Expecting the highest measurement instead of the latest key.
Formal Syntax & Structure
rust syntaxrust
fn last_key_value(&self) -> Option<(&K, &V)>Working Example
Example Snippetrust
fn main() { use std::collections::BTreeMap; let readings = BTreeMap::from([(1, 99), (5, 42)]); println!("{:?}", readings.last_key_value());}