Struct unc_sdk::store::iterable_map::VacantEntry
source · pub struct VacantEntry<'a, K, V, H>{ /* private fields */ }Expand description
View into a vacant entry in a IterableMap.
This is part of the Entry enum.
Implementations§
source§impl<'a, K, V, H> VacantEntry<'a, K, V, H>
impl<'a, K, V, H> VacantEntry<'a, K, V, H>
sourcepub 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.
sourcepub fn into_key(self) -> K
pub fn into_key(self) -> K
Take ownership of the key.
§Examples
use unc_sdk::store::IterableMap;
use unc_sdk::store::iterable_map::Entry;
let mut map: IterableMap<String, u32> = IterableMap::new(b"m");
if let Entry::Vacant(v) = map.entry("poneyland".to_string()) {
v.into_key();
}sourcepub fn insert(self, value: V) -> &'a mut Vwhere
K: BorshDeserialize + Clone,
pub fn insert(self, value: V) -> &'a mut Vwhere
K: BorshDeserialize + Clone,
Sets the value of the entry with the VacantEntry’s key,
and returns a mutable reference to it.
§Examples
use unc_sdk::store::IterableMap;
use unc_sdk::store::iterable_map::Entry;
let mut map: IterableMap<String, u32> = IterableMap::new(b"m");
if let Entry::Vacant(o) = map.entry("poneyland".to_string()) {
o.insert(37);
}
assert_eq!(map["poneyland"], 37);Auto Trait Implementations§
impl<'a, K, V, H> Freeze for VacantEntry<'a, K, V, H>where
K: Freeze,
impl<'a, K, V, H> !RefUnwindSafe for VacantEntry<'a, K, V, H>
impl<'a, K, V, H> Send for VacantEntry<'a, K, V, H>
impl<'a, K, V, H> !Sync for VacantEntry<'a, K, V, H>
impl<'a, K, V, H> Unpin for VacantEntry<'a, K, V, H>where
K: Unpin,
impl<'a, K, V, H> !UnwindSafe for VacantEntry<'a, K, V, H>
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