std-method

BTreeMap::new

Create an empty ordered dictionary. Give the compiler key and value types when later operations do not determine them. Expected stdout (not executed): true 1 Common mistake: Confusing an empty map with a map of zero-valued entries.

Formal Syntax & Structure

rust syntaxrust
fn new() -> BTreeMap<K, V>

Working Example

Example Snippetrust
fn main() {    use std::collections::BTreeMap;    let mut prices: BTreeMap<&str, u32> = BTreeMap::new();    println!("{}", prices.is_empty());    prices.insert("tea", 8);    println!("{}", prices.len());}
Rust Reference