pub struct VacantEntry<'a, K: 'a, V: 'a> { /* fields omitted */ }Expand description
BTreeMap 中空条目的视图。
它是 Entry 枚举的一部分。
获取对通过 VacantEntry 插入值时将使用的键的引用。
use std::collections::BTreeMap;
let mut map: BTreeMap<&str, usize> = BTreeMap::new();
assert_eq!(map.entry("poneyland").key(), &"poneyland");Run 
取得键的所有权。
use std::collections::BTreeMap;
use std::collections::btree_map::Entry;
let mut map: BTreeMap<&str, usize> = BTreeMap::new();
if let Entry::Vacant(v) = map.entry("poneyland") {
    v.into_key();
}Run 
用 VacantEntry 的键设置条目的值,并返回对它的可变引用。
use std::collections::BTreeMap;
use std::collections::btree_map::Entry;
let mut map: BTreeMap<&str, u32> = BTreeMap::new();
if let Entry::Vacant(o) = map.entry("poneyland") {
    o.insert(37);
}
assert_eq!(map["poneyland"], 37);Run