Skip to main content

EntryRef

Struct EntryRef 

Source
pub struct EntryRef<'map, K, V, const N: usize = DEFAULT_PAGE_CAPACITY> { /* private fields */ }
Expand description

A read guard for an entry in a BLinkMap.

The guard keeps its leaf read-locked. This makes the returned key and value references stable until the guard is dropped.

§Locking

Drop this guard before calling a map operation that may need the same leaf, especially BLinkMap::insert, BLinkMap::remove, or BLinkMap::get_mut. Retaining it can self-deadlock. Holding several entry guards while acquiring more guards in inconsistent orders can likewise create a cross-thread lock cycle.

Implementations§

Source§

impl<K, V, const N: usize> EntryRef<'_, K, V, N>

Source

pub fn key(&self) -> &K

Returns the entry’s immutable key.

Source

pub fn value(&self) -> &V

Returns the entry’s immutable value.

Examples found in repository?
examples/basic.rs (line 14)
3fn main() {
4  let map = BLinkMap::<u64, String>::new();
5  map.insert(7, String::from("seven"));
6
7  let set = BLinkSet::<u64>::new();
8  set.insert(7);
9
10  let value = map.get(&7).expect("the example inserted key 7");
11
12  println!(
13    "map[7] = {}, set contains 7 = {}",
14    value.value(),
15    set.contains(&7)
16  );
17}

Trait Implementations§

Source§

impl<K: Debug, V: Debug, const N: usize> Debug for EntryRef<'_, K, V, N>

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K, V, const N: usize> Deref for EntryRef<'_, K, V, N>

Source§

type Target = V

The resulting type after dereferencing.
Source§

fn deref(&self) -> &V

Dereferences the value.

Auto Trait Implementations§

§

impl<'map, K, V, const N: usize = DEFAULT_PAGE_CAPACITY> !RefUnwindSafe for EntryRef<'map, K, V, N>

§

impl<'map, K, V, const N: usize = DEFAULT_PAGE_CAPACITY> !Send for EntryRef<'map, K, V, N>

§

impl<'map, K, V, const N: usize = DEFAULT_PAGE_CAPACITY> !UnwindSafe for EntryRef<'map, K, V, N>

§

impl<'map, K, V, const N: usize> Freeze for EntryRef<'map, K, V, N>
where ArcRwLockReadGuard<RawRwLock, Node<K, V, N>>: Freeze, PhantomData<&'map BLinkMap<K, V, N>>: Freeze,

§

impl<'map, K, V, const N: usize> Sync for EntryRef<'map, K, V, N>
where ArcRwLockReadGuard<RawRwLock, Node<K, V, N>>: Sync, PhantomData<&'map BLinkMap<K, V, N>>: Sync,

§

impl<'map, K, V, const N: usize> Unpin for EntryRef<'map, K, V, N>
where ArcRwLockReadGuard<RawRwLock, Node<K, V, N>>: Unpin, PhantomData<&'map BLinkMap<K, V, N>>: Unpin,

§

impl<'map, K, V, const N: usize> UnsafeUnpin for EntryRef<'map, K, V, N>
where ArcRwLockReadGuard<RawRwLock, Node<K, V, N>>: UnsafeUnpin, PhantomData<&'map BLinkMap<K, V, N>>: UnsafeUnpin,

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.