[][src]Enum contrie::ExistingOrNew

pub enum ExistingOrNew<T> {
    Existing(T),
    New(T),
}

A simple enum to make a distinction if the returned value is an already existing one or a newly created instance.

As it dereferences to the held value, it acts almost as the value T in many circumstances. Otherwise it can also be extracted.

Variants

Existing(T)

The entry already existed.

New(T)

A new entry had to be inserted to satisfy the request.

Methods

impl<T> ExistingOrNew<T>[src]

pub fn into_inner(self) -> T[src]

Extracts the inner value.

pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> ExistingOrNew<U>[src]

Applies a transformation to the value.

This applies the function to the inner value, but preserves the information if it was a new or existing one.

pub fn is_new(&self) -> bool[src]

Checks if the value was newly created one.

Trait Implementations

impl<T: PartialEq> PartialEq<ExistingOrNew<T>> for ExistingOrNew<T>[src]

impl<T: Clone> Clone for ExistingOrNew<T>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<T: PartialOrd> PartialOrd<ExistingOrNew<T>> for ExistingOrNew<T>[src]

impl<T: Eq> Eq for ExistingOrNew<T>[src]

impl<T: Ord> Ord for ExistingOrNew<T>[src]

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl<T: Copy> Copy for ExistingOrNew<T>[src]

impl<T> DerefMut for ExistingOrNew<T>[src]

impl<T> Deref for ExistingOrNew<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T: Debug> Debug for ExistingOrNew<T>[src]

impl<T: Hash> Hash for ExistingOrNew<T>[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given [Hasher]. Read more

Auto Trait Implementations

impl<T> Unpin for ExistingOrNew<T> where
    T: Unpin

impl<T> Sync for ExistingOrNew<T> where
    T: Sync

impl<T> Send for ExistingOrNew<T> where
    T: Send

impl<T> RefUnwindSafe for ExistingOrNew<T> where
    T: RefUnwindSafe

impl<T> UnwindSafe for ExistingOrNew<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]