moka::ops::compute

Enum CompResult

source
pub enum CompResult<K, V> {
    StillNone(Arc<K>),
    Unchanged(Entry<K, V>),
    Inserted(Entry<K, V>),
    ReplacedWith(Entry<K, V>),
    Removed(Entry<K, V>),
}
Expand description

The result of the and_compute_with and similar methods.

Variants§

§

StillNone(Arc<K>)

The entry did not exist and still does not exist.

§

Unchanged(Entry<K, V>)

The entry already existed and was not modified. The returned entry contains the existing value.

§

Inserted(Entry<K, V>)

The entry did not exist and was inserted. The returned entry contains the inserted value.

§

ReplacedWith(Entry<K, V>)

The entry already existed and its value was replaced with a new one. The returned entry contains the new value (not the replaced value).

§

Removed(Entry<K, V>)

The entry already existed and was removed. The returned entry contains the removed value.

Note: StillNone is returned instead of Removed if Op::Remove was requested but the entry did not exist.

Implementations§

source§

impl<K, V> CompResult<K, V>

source

pub fn into_entry(self) -> Option<Entry<K, V>>

Returns the contained Some(Entry) if any. Otherwise returns None. Consumes the self value.

source

pub fn unwrap(self) -> Entry<K, V>

Unwraps the contained Entry, consuming the self value.

§Panics

Panics if the self value is StillNone.

Trait Implementations§

source§

impl<K: Debug, V: Debug> Debug for CompResult<K, V>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<K, V> Freeze for CompResult<K, V>
where V: Freeze,

§

impl<K, V> RefUnwindSafe for CompResult<K, V>

§

impl<K, V> Send for CompResult<K, V>
where K: Sync + Send, V: Send,

§

impl<K, V> Sync for CompResult<K, V>
where K: Sync + Send, V: Sync,

§

impl<K, V> Unpin for CompResult<K, V>
where V: Unpin,

§

impl<K, V> UnwindSafe for CompResult<K, V>

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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
source§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.