Entry

Struct Entry 

Source
pub struct Entry<'a, R, ChunkKey, ItemKey, Element>
where R: Record<ChunkKey, ItemKey> + 'a, ChunkKey: BorrowedKey + ?Sized, ChunkKey::Owned: ValidKey, ItemKey: BorrowedKey + ?Sized, ItemKey::Owned: ValidKey,
{ /* private fields */ }
Expand description

An Entry for an element. This is intended to work in the same way as the Entries from rust’s standard collections API. An Entry refers to an element that we have tried to look up and might or might not have found.

§Type Parameters

  • R: The key used to lookup this Entry
  • ChunkKey: The chunk key type of the backing Storage
  • ItemKey: The item key type of the backing Storage
  • Element: The element type of the backing Storage, and also the Element represented by this Entry.

Implementations§

Source§

impl<'a, R, ChunkKey, ItemKey, Element> Entry<'a, R, ChunkKey, ItemKey, Element>
where R: Record<ChunkKey, ItemKey> + 'a, ChunkKey: BorrowedKey + ?Sized, ChunkKey::Owned: ValidKey, ItemKey: BorrowedKey + ?Sized, ItemKey::Owned: ValidKey, Element: Record<ChunkKey, ItemKey>,

Source

pub fn id(&self) -> &R

Returns the value whose ChunkKey and ItemKey is used to look up this Entry.

Source

pub fn or_insert_with<F>(self, f: F) -> &'a mut Element
where F: FnOnce() -> Element,

Insert a record at this entry if it does not already exist.

Source

pub fn and_modify<F>(self, f: F) -> Self
where F: FnOnce(&mut Element),

Modify this element if it exists. If the element does not exist, nothing happens.

Source

pub fn or_panic(self) -> Self
where R: Debug,

Panic if this element doesn’t exist in Storage.

Source

pub fn get(&self) -> Option<&Element>

Get a reference to the element.

Source

pub fn get_mut(&mut self) -> Option<&mut Element>

Get a mutable reference to the element.

Source

pub fn remove(self) -> Option<Element>

Remove and return the element.

Source

pub fn remove_if<F>(self, f: F) -> Option<Element>
where F: FnMut(&Element) -> bool,

Remove and return the element, only if the predicate is true.

Auto Trait Implementations§

§

impl<'a, R, ChunkKey, ItemKey, Element> Freeze for Entry<'a, R, ChunkKey, ItemKey, Element>
where <ItemKey as ToOwned>::Owned: Sized, <ChunkKey as ToOwned>::Owned: Sized, R: Freeze, ChunkKey: ?Sized, ItemKey: ?Sized,

§

impl<'a, R, ChunkKey, ItemKey, Element> RefUnwindSafe for Entry<'a, R, ChunkKey, ItemKey, Element>
where <ItemKey as ToOwned>::Owned: Sized + RefUnwindSafe, <ChunkKey as ToOwned>::Owned: Sized + RefUnwindSafe, R: RefUnwindSafe, Element: RefUnwindSafe, ChunkKey: ?Sized, ItemKey: ?Sized,

§

impl<'a, R, ChunkKey, ItemKey, Element> Send for Entry<'a, R, ChunkKey, ItemKey, Element>
where <ItemKey as ToOwned>::Owned: Sized + Send, <ChunkKey as ToOwned>::Owned: Sized + Send, R: Send, Element: Send, ChunkKey: ?Sized, ItemKey: ?Sized,

§

impl<'a, R, ChunkKey, ItemKey, Element> Sync for Entry<'a, R, ChunkKey, ItemKey, Element>
where <ItemKey as ToOwned>::Owned: Sized + Sync, <ChunkKey as ToOwned>::Owned: Sized + Sync, R: Sync, Element: Sync, ChunkKey: ?Sized, ItemKey: ?Sized,

§

impl<'a, R, ChunkKey, ItemKey, Element> Unpin for Entry<'a, R, ChunkKey, ItemKey, Element>
where <ItemKey as ToOwned>::Owned: Sized, <ChunkKey as ToOwned>::Owned: Sized, R: Unpin, ChunkKey: ?Sized, ItemKey: ?Sized,

§

impl<'a, R, ChunkKey, ItemKey, Element> !UnwindSafe for Entry<'a, R, ChunkKey, ItemKey, Element>

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.