Skip to main content

Either

Enum Either 

Source
pub enum Either<Own, Base> {
    Own(Own),
    Direct(Base),
}
Expand description

A 2-variant generic enum, useful for writing implementations that provide some own variants on those passed on directly to a base.

It implements various traits depending on the own and base trait; currently, just as AsRef.

§Caveats

Do not use this to extend own enums, as those will become types with their fixed layout that might easily use the very same discriminator field as the underlying type, and thus defeat possible optimizations.

Variants§

§

Own(Own)

§

Direct(Base)

Trait Implementations§

Source§

impl<T: ?Sized, Own: AsRef<T>, Base: AsRef<T>> AsRef<T> for Either<Own, Base>

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<Own: Clone, Base: Clone> Clone for Either<Own, Base>

Source§

fn clone(&self) -> Self

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<Own: Debug, Base: Debug> Debug for Either<Own, Base>

Source§

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

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

impl<Own: Eq, Base: Eq> Eq for Either<Own, Base>

Source§

impl<Own: PartialEq, Base: PartialEq> PartialEq for Either<Own, Base>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<Own: PartialEq, Base: PartialEq> StructuralPartialEq for Either<Own, Base>

Auto Trait Implementations§

§

impl<Own, Base> Freeze for Either<Own, Base>
where Own: Freeze, Base: Freeze,

§

impl<Own, Base> RefUnwindSafe for Either<Own, Base>
where Own: RefUnwindSafe, Base: RefUnwindSafe,

§

impl<Own, Base> Send for Either<Own, Base>
where Own: Send, Base: Send,

§

impl<Own, Base> Sync for Either<Own, Base>
where Own: Sync, Base: Sync,

§

impl<Own, Base> Unpin for Either<Own, Base>
where Own: Unpin, Base: Unpin,

§

impl<Own, Base> UnsafeUnpin for Either<Own, Base>
where Own: UnsafeUnpin, Base: UnsafeUnpin,

§

impl<Own, Base> UnwindSafe for Either<Own, Base>
where Own: UnwindSafe, Base: 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.