pub enum Augmented<T, A: Clone> {
Primary(T),
WithAux(T, A),
}Expand description
An Augmented value is a generic wrapper that holds a primary value of type T and an
optional auxiliary value of type A.
This is useful when a function needs to return a value that has some additional, optional
context attached to it. For example, A can be used to override some of the fields of T
without modifying T itself.
Variants§
Primary(T)
The primary value, without any auxiliary data.
WithAux(T, A)
The primary value, with auxiliary data.
Implementations§
Source§impl<T, A: Clone> Augmented<T, A>
impl<T, A: Clone> Augmented<T, A>
Sourcepub fn map<U>(self, f: impl FnOnce(T) -> U) -> Augmented<U, A>
pub fn map<U>(self, f: impl FnOnce(T) -> U) -> Augmented<U, A>
Maps an Augmented<T, A> to an Augmented<U, A> by applying a function to the contained
primary value, leaving the auxiliary value untouched.
Trait Implementations§
impl<T: Copy, A: Copy + Clone> Copy for Augmented<T, A>
impl<T: Eq, A: Eq + Clone> Eq for Augmented<T, A>
impl<T, A: Clone> StructuralPartialEq for Augmented<T, A>
Auto Trait Implementations§
impl<T, A> Freeze for Augmented<T, A>
impl<T, A> RefUnwindSafe for Augmented<T, A>where
T: RefUnwindSafe,
A: RefUnwindSafe,
impl<T, A> Send for Augmented<T, A>
impl<T, A> Sync for Augmented<T, A>
impl<T, A> Unpin for Augmented<T, A>
impl<T, A> UnwindSafe for Augmented<T, A>where
T: UnwindSafe,
A: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more