Skip to main content

Either

Enum Either 

Source
pub enum Either<L, R> {
    Left(L),
    Right(R),
}

Variants§

§

Left(L)

§

Right(R)

Implementations§

Source§

impl<L, R> Either<L, R>

Source

pub const fn new_left(l: L) -> Self

Source

pub const fn new_right(r: R) -> Self

Source

pub fn split(self) -> (Option<L>, Option<R>)

Source

pub fn map_left<F, T>(self, f: F) -> Either<T, R>
where F: FnOnce(L) -> T,

Maps Either<L, R> to Either<T, R>

Source

pub fn map_right<F, T>(self, f: F) -> Either<L, T>
where F: FnOnce(R) -> T,

Maps Either<L, R> to Either<L, T>

Source

pub fn take_left(self) -> Either<L, Self>

Source

pub fn take_right(self) -> Either<R, Self>

Source

pub const fn as_ref(&self) -> Either<&L, &R>

Source

pub const fn as_mut(&mut self) -> Either<&mut L, &mut R>

Source

pub fn left(self) -> Option<L>

Source

pub fn right(self) -> Option<R>

Source

pub fn reverse(self) -> Either<R, L>

Source

pub const fn is_left(&self) -> bool

Source

pub const fn is_right(&self) -> bool

Source

pub fn is_left_and<F>(&self, f: F) -> bool
where F: FnOnce(&L) -> bool,

Source

pub fn is_right_and<F>(&self, f: F) -> bool
where F: FnOnce(&R) -> bool,

Source§

impl<T> Either<T, T>

Source

pub fn into_inner(self) -> T

Trait Implementations§

Source§

impl<L: Clone, R: Clone> Clone for Either<L, R>

Source§

fn clone(&self) -> Either<L, R>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<L: Debug, R: Debug> Debug for Either<L, R>

Source§

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

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

impl<L, R> From<Either<L, R>> for Any<L, R>

Source§

fn from(value: Either<L, R>) -> Self

Converts to this type from the input type.
Source§

impl<L, R> From<Either<L, R>> for SomeOf<L, R>

Source§

fn from(value: Either<L, R>) -> Self

Converts to this type from the input type.
Source§

impl<L> From<Option<L>> for Either<L, ()>

Source§

fn from(value: Option<L>) -> Self

Converts to this type from the input type.
Source§

impl<T, E> From<Result<T, E>> for Either<T, E>

Source§

fn from(value: Result<T, E>) -> Self

Converts to this type from the input type.
Source§

impl<L, R> TrAnyLeftRight for Either<L, R>

Source§

type Lt = L

Source§

type Rt = R

Source§

fn split(self) -> (Option<Self::Lt>, Option<Self::Rt>)

Source§

fn map_left<F, T>(self, f: F) -> impl TrAnyLeftRight<Lt = T, Rt = Self::Rt>
where F: FnOnce(Self::Lt) -> T,

Source§

fn map_right<F, T>(self, f: F) -> impl TrAnyLeftRight<Lt = Self::Lt, Rt = T>
where F: FnOnce(Self::Rt) -> T,

Source§

fn take_left(self) -> SomeOf<Self::Lt, Self>
where Self: Sized,

Source§

fn take_right(self) -> SomeOf<Self::Rt, Self>
where Self: Sized,

Source§

fn as_ref<'a>( &'a self, ) -> impl TrAnyLeftRight<Lt = &'a Self::Lt, Rt = &'a Self::Rt>
where Self::Lt: 'a, Self::Rt: 'a,

Source§

fn as_mut<'a>( &'a mut self, ) -> impl TrAnyLeftRight<Lt = &'a mut Self::Lt, Rt = &'a mut Self::Rt>
where Self::Lt: 'a, Self::Rt: 'a,

Source§

fn contains_left(&self) -> bool

Source§

fn contains_right(&self) -> bool

Source§

fn pick_left(self) -> Option<Self::Lt>
where Self: Sized,

Source§

fn pick_right(self) -> Option<Self::Rt>
where Self: Sized,

Source§

fn contains_left_and<F>(&self, f: F) -> bool
where F: FnOnce(&Self::Lt) -> bool,

Source§

fn contains_right_and<F>(&self, f: F) -> bool
where F: FnOnce(&Self::Rt) -> bool,

Source§

impl<L, R> TrReverseLeftRight for Either<L, R>

Source§

type Lt = L

Source§

type Rt = R

Source§

fn reverse(self) -> impl TrReverseLeftRight<Lt = Self::Rt, Rt = Self::Lt>

Source§

impl<L: Copy, R: Copy> Copy for Either<L, R>

Auto Trait Implementations§

§

impl<L, R> Freeze for Either<L, R>
where L: Freeze, R: Freeze,

§

impl<L, R> RefUnwindSafe for Either<L, R>

§

impl<L, R> Send for Either<L, R>
where L: Send, R: Send,

§

impl<L, R> Sync for Either<L, R>
where L: Sync, R: Sync,

§

impl<L, R> Unpin for Either<L, R>
where L: Unpin, R: Unpin,

§

impl<L, R> UnsafeUnpin for Either<L, R>
where L: UnsafeUnpin, R: UnsafeUnpin,

§

impl<L, R> UnwindSafe for Either<L, R>
where L: UnwindSafe, R: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.