Struct scc::hash_map::VacantEntry
source · pub struct VacantEntry<'h, K, V, H = RandomState>where
K: Eq + Hash,
H: BuildHasher,{ /* private fields */ }Expand description
VacantEntry is a view into a vacant entry in a HashMap.
Implementations§
source§impl<'h, K, V, H> VacantEntry<'h, K, V, H>where
K: Eq + Hash,
H: BuildHasher,
impl<'h, K, V, H> VacantEntry<'h, K, V, H>where K: Eq + Hash, H: BuildHasher,
sourcepub fn key(&self) -> &K
pub fn key(&self) -> &K
Gets a reference to the key.
Examples
use scc::HashMap;
let hashmap: HashMap<u64, u32> = HashMap::default();
assert_eq!(hashmap.entry(11).key(), &11);sourcepub fn into_key(self) -> K
pub fn into_key(self) -> K
Takes ownership of the key.
Examples
use scc::HashMap;
use scc::hash_map::Entry;
let hashmap: HashMap<u64, u32> = HashMap::default();
if let Entry::Vacant(v) = hashmap.entry(17) {
assert_eq!(v.into_key(), 17);
};sourcepub fn insert_entry(self, val: V) -> OccupiedEntry<'h, K, V, H>
pub fn insert_entry(self, val: V) -> OccupiedEntry<'h, K, V, H>
Sets the value of the entry with its key, and returns an OccupiedEntry.
Examples
use scc::HashMap;
use scc::hash_map::Entry;
let hashmap: HashMap<u64, u32> = HashMap::default();
if let Entry::Vacant(o) = hashmap.entry(19) {
o.insert_entry(29);
}
assert_eq!(hashmap.read(&19, |_, v| *v), Some(29));