std-method
BTreeMap::first_key_value
Inspect the earliest key without removing its record. The empty case is explicit. Expected stdout (not executed): Some((3, "email")) Common mistake: Treating the first key as the first inserted key.
Formal Syntax & Structure
rust syntaxrust
fn first_key_value(&self) -> Option<(&K, &V)>Working Example
Example Snippetrust
fn main() { use std::collections::BTreeMap; let deadlines = BTreeMap::from([(20, "report"), (3, "email")]); println!("{:?}", deadlines.first_key_value());}