Ref

Struct Ref 

Source
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>
where A: Allocator, V: Value,

Source

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.

Source

pub fn key(&mut self) -> Option<K>
where K: Eq + Hash + Copy, H: BuildHasher + Default,

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

Source

pub fn value(&mut self) -> Option<V>
where K: Eq + Hash + Copy, H: BuildHasher + Default,

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

Source

pub fn key_value(&mut self) -> Option<(K, V)>
where K: Eq + Hash + Copy, H: BuildHasher + Default,

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.

Auto Trait Implementations§

§

impl<'a, K, V, H, A> Freeze for Ref<'a, K, V, H, A>

§

impl<'a, K, V, H, A> !RefUnwindSafe for Ref<'a, K, V, H, A>

§

impl<'a, K, V, H, A> Send for Ref<'a, K, V, H, A>
where H: Sync, A: Sync, K: Copy + Send, V: Copy + Send,

§

impl<'a, K, V, H, A> Sync for Ref<'a, K, V, H, A>
where H: Sync, A: Sync, K: Copy + Send, V: Copy + Send,

§

impl<'a, K, V, H, A> Unpin for Ref<'a, K, V, H, A>

§

impl<'a, K, V, H, A> !UnwindSafe for Ref<'a, K, V, H, A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.