pub type IdVacantEntry<'a, K, V> = VacantEntry<'a, K, V, BuildIdHasher>;
Expand description
Vacant entry in an IdEntry
.
Aliased Type§
struct IdVacantEntry<'a, K, V> { /* private fields */ }
Implementations
§impl<'a, K, V, S, A> VacantEntry<'a, K, V, S, A>where
A: Allocator,
impl<'a, K, V, S, A> VacantEntry<'a, K, V, S, A>where
A: Allocator,
pub fn key(&self) -> &K
pub fn key(&self) -> &K
Gets a reference to the key that would be used when inserting a value
through the VacantEntry
.
§Examples
use hashbrown::HashMap;
let mut map: HashMap<&str, u32> = HashMap::new();
assert_eq!(map.entry("poneyland").key(), &"poneyland");
pub fn into_key(self) -> K
pub fn into_key(self) -> K
Take ownership of the key.
§Examples
use hashbrown::hash_map::{Entry, HashMap};
let mut map: HashMap<&str, u32> = HashMap::new();
match map.entry("poneyland") {
Entry::Occupied(_) => panic!(),
Entry::Vacant(v) => assert_eq!(v.into_key(), "poneyland"),
}
pub fn insert(self, value: V) -> &'a mut Vwhere
K: Hash,
S: BuildHasher,
pub fn insert(self, value: V) -> &'a mut Vwhere
K: Hash,
S: BuildHasher,
Sets the value of the entry with the [VacantEntry
]’s key,
and returns a mutable reference to it.
§Examples
use hashbrown::HashMap;
use hashbrown::hash_map::Entry;
let mut map: HashMap<&str, u32> = HashMap::new();
if let Entry::Vacant(o) = map.entry("poneyland") {
o.insert(37);
}
assert_eq!(map["poneyland"], 37);
pub fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V, S, A>where
K: Hash,
S: BuildHasher,
pub fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V, S, A>where
K: Hash,
S: BuildHasher,
Sets the value of the entry with the [VacantEntry
]’s key,
and returns an [OccupiedEntry
].
§Examples
use hashbrown::HashMap;
use hashbrown::hash_map::Entry;
let mut map: HashMap<&str, u32> = HashMap::new();
if let Entry::Vacant(v) = map.entry("poneyland") {
let o = v.insert_entry(37);
assert_eq!(o.get(), &37);
}