pub struct Ref<'a, K, V, H, A: Allocator> { /* private fields */ }Expand description
A reference to an atomic cell in a LeapMap, which cannot mutate the referenced cell value.
Implementations§
Source§impl<'a, K, V, H, A> Ref<'a, K, V, H, A>
impl<'a, K, V, H, A> Ref<'a, K, V, H, A>
Sourcepub fn new(
map: &'a LeapMap<K, V, H, A>,
cell: &'a AtomicCell<K, V>,
hash: u64,
) -> Ref<'a, K, V, H, A>
pub fn new( map: &'a LeapMap<K, V, H, A>, cell: &'a AtomicCell<K, V>, hash: u64, ) -> Ref<'a, K, V, H, A>
Creates a new ref type referencing the specified cell and map.
Sourcepub fn key(&mut self) -> Option<K>
pub fn key(&mut self) -> Option<K>
Loads the key for the referenced cell.
This requires &mut self since it’s possible that the underlying data
for the map has been migrated, and that therefore the referenced cell
is out of date, and returning the current value will be incorrect. In
such a case, the cell needs to be updated to reference the correct cell,
hence mut self. This ensures that the returned value is always the
most up to date value.
It is also possible that the cell has been deleted, in which case the
returned value will be None
Sourcepub fn value(&mut self) -> Option<V>
pub fn value(&mut self) -> Option<V>
Loads the value for the referenced cell.
This requires &mut self since it’s possible that the underlying data
for the map has been migrated, and that therefore the referenced cell
is out of date, and returning the current value will be incorrect. In
such a case, the cell needs to be updated to reference the correct cell,
hence mut self. This ensures that the returned value is always the
most up to date value.
It is also possible that the cell has been deleted, in which case the
returned value will be None
Sourcepub fn key_value(&mut self) -> Option<(K, V)>
pub fn key_value(&mut self) -> Option<(K, V)>
Loads the key-value pair for the referenced cell.
This requires &mut self since it’s possible that the underlying data
for the map has been migrated, and that therefore the referenced cell
is out of date, and returning the current value will be incorrect. In
such a case, the cell needs to be updated to reference the correct cell,
hence mut self. This ensures that the returned value is always the
most up to date value.
It is also possible that the cell has been deleted, in which case the
returned value will be None.