pub struct VacantEntry<'a, K1: 'a, K2: 'a, V: 'a> { /* private fields */ }Implementations§
Source§impl<'a, K1: 'a, K2: 'a, V: 'a> VacantEntry<'a, K1, K2, V>
impl<'a, K1: 'a, K2: 'a, V: 'a> VacantEntry<'a, K1, K2, V>
Sourcepub fn key1(&self) -> &K1
pub fn key1(&self) -> &K1
Gets a reference to the key #1 of type K1 that would be used
when inserting a value through the VacantEntry.
§Examples
use double_map::DHashMap;
use double_map::dhash_map::Entry;
let mut map: DHashMap<&str, u32, i32> = DHashMap::new();
if let Ok(entry) = map.entry("poneyland", 0) {
match entry {
Entry::Occupied(_) => panic!("Something go wrong!!!"),
Entry::Vacant(vac_entry) => assert_eq!(vac_entry.key1(), &"poneyland"),
}
}Sourcepub fn key2(&self) -> &K2
pub fn key2(&self) -> &K2
Gets a reference to the key #2 of type K2 that would be used
when inserting a value through the VacantEntry.
§Examples
use double_map::DHashMap;
use double_map::dhash_map::Entry;
let mut map: DHashMap<&str, u32, i32> = DHashMap::new();
if let Ok(entry) = map.entry("poneyland", 0) {
match entry {
Entry::Occupied(_) => panic!("Something go wrong!!!"),
Entry::Vacant(vac_entry) => assert_eq!(vac_entry.key2(), &0),
}
}Sourcepub fn keys(&self) -> (&K1, &K2)
pub fn keys(&self) -> (&K1, &K2)
Gets a reference to the keys of type K1 and K2 that would be used
when inserting a value through the VacantEntry.
Return tuple of type (&'a K1, &'a K2).
§Examples
use double_map::DHashMap;
use double_map::dhash_map::Entry;
let mut map: DHashMap<&str, u32, i32> = DHashMap::new();
if let Ok(entry) = map.entry("poneyland", 0) {
match entry {
Entry::Occupied(_) => panic!("Something go wrong!!!"),
Entry::Vacant(vac_entry) => {
assert_eq!(vac_entry.keys(), (&"poneyland", &0))
}
}
}Sourcepub fn into_keys(self) -> (K1, K2)
pub fn into_keys(self) -> (K1, K2)
Take the ownership of the keys from the entry.
§Examples
use double_map::DHashMap;
use double_map::dhash_map::Entry;
// So lets create some map and also reserve some space for additional elements
let mut map: DHashMap<&str, u32, i32> = DHashMap::with_capacity(3);
let capacity_before_into_keys = map.capacity();
assert!(capacity_before_into_keys >= 3);
if let Ok(entry) = map.entry("poneyland", 0) {
match entry {
Entry::Occupied(_) => panic!("Something go wrong!!!"),
Entry::Vacant(vac_entry) => {
// We take the keys from the entry.
let tuple = vac_entry.into_keys();
assert_eq!(tuple, ("poneyland", 0));
}
}
}
if let Ok(entry) = map.entry("bearland", 1) {
match entry {
Entry::Occupied(_) => panic!("Something go wrong!!!"),
Entry::Vacant(vac_entry) => {
// We take the keys from the entry.
let tuple = vac_entry.into_keys();
assert_eq!(tuple, ("bearland", 1));
}
}
}
map.entry("some_key", 2);
map.entry("another_key", 3);
// The capacity of our map is not changed
assert_eq!(map.capacity(), capacity_before_into_keys);Source§impl<'a, K1: 'a + Clone, K2: 'a + Clone, V: 'a> VacantEntry<'a, K1, K2, V>
impl<'a, K1: 'a + Clone, K2: 'a + Clone, V: 'a> VacantEntry<'a, K1, K2, V>
Sourcepub fn insert(self, value: V) -> &'a mut V
pub fn insert(self, value: V) -> &'a mut V
Sets the value of the entry with the VacantEntry’s keys,
and returns a mutable reference to it.
§Examples
use double_map::DHashMap;
use double_map::dhash_map::Entry;
// So lets create some map
let mut map: DHashMap<&str, u32, i32> = DHashMap::new();
if let Ok(entry) = map.entry("poneyland", 0) {
match entry {
Entry::Occupied(_) => panic!("Something go wrong!!!"),
Entry::Vacant(vac_entry) => {
vac_entry.insert(37);
}
}
}
assert_eq!(map.get_key1(&"poneyland"), Some(&37));Trait Implementations§
Auto Trait Implementations§
impl<'a, K1, K2, V> Freeze for VacantEntry<'a, K1, K2, V>
impl<'a, K1, K2, V> RefUnwindSafe for VacantEntry<'a, K1, K2, V>
impl<'a, K1, K2, V> Send for VacantEntry<'a, K1, K2, V>
impl<'a, K1, K2, V> Sync for VacantEntry<'a, K1, K2, V>
impl<'a, K1, K2, V> Unpin for VacantEntry<'a, K1, K2, V>
impl<'a, K1, K2, V> !UnwindSafe for VacantEntry<'a, K1, K2, V>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more