Enum Either
pub enum Either<L, R>
The enum Either with variants Left and Right is a general purpose
sum type with two cases.
The Either type is symmetric and treats its variants the same way, without
preference.
(For representing success or error, use the regular Result enum instead.)
Variants
-
Left(L) A value of type
L.-
Right(R) A value of type
R.
Implementations
impl<L, R> Either<&L, &R>
fn cloned(self) -> Either<L, R> where L: Clone, R: Clone,Maps an
Either<&L, &R>to anEither<L, R>by cloning the contents of either branch.fn copied(self) -> Either<L, R> where L: Copy, R: Copy,Maps an
Either<&L, &R>to anEither<L, R>by copying the contents of either branch.
impl<L, R> Either<&mut L, &mut R>
fn cloned(self) -> Either<L, R> where L: Clone, R: Clone,Maps an
Either<&mut L, &mut R>to anEither<L, R>by cloning the contents of either branch.fn copied(self) -> Either<L, R> where L: Copy, R: Copy,Maps an
Either<&mut L, &mut R>to anEither<L, R>by copying the contents of either branch.
impl<L, R> Either<L, R>
fn is_left(&self) -> boolReturn true if the value is the
Leftvariant.use *; let values = ; assert_eq!; assert_eq!;fn is_left_and<F>(self, f: F) -> bool where F: FnOnce(L) -> bool,Returns
trueif the value isLeftand the value inside of it matches a predicate.Examples
use *; let left0: = Left; let left2: = Left; let right: = Right; assert_eq!; assert_eq!; assert_eq!;fn is_right_and<F>(self, f: F) -> bool where F: FnOnce(R) -> bool,Returns
trueif the value isRightand the value inside of it matches a predicate.Examples
use *; let right0: = Right; let right2: = Right; let left: = Left; assert_eq!; assert_eq!; assert_eq!;fn is_right(&self) -> boolReturn true if the value is the
Rightvariant.use *; let values = ; assert_eq!; assert_eq!;fn left(self) -> Option<L>Convert the left side of
Either<L, R>to anOption<L>.use *; let left: = Left; assert_eq!; let right: = Right; assert_eq!;fn right(self) -> Option<R>Convert the right side of
Either<L, R>to anOption<R>.use *; let left: = Left; assert_eq!; let right: = Right; assert_eq!;fn as_ref(&self) -> Either<&L, &R>Convert
&Either<L, R>toEither<&L, &R>.use *; let left: = Left; assert_eq!; let right: = Right; assert_eq!;fn as_mut(&mut self) -> Either<&mut L, &mut R>Convert
&mut Either<L, R>toEither<&mut L, &mut R>.use *; let mut left = Left; let mut right = Right; mutate_left; mutate_left; assert_eq!; assert_eq!;fn as_pin_ref(self: Pin<&Self>) -> Either<Pin<&L>, Pin<&R>>Convert
Pin<&Either<L, R>>toEither<Pin<&L>, Pin<&R>>, pinned projections of the inner variants.fn as_pin_mut(self: Pin<&mut Self>) -> Either<Pin<&mut L>, Pin<&mut R>>Convert
Pin<&mut Either<L, R>>toEither<Pin<&mut L>, Pin<&mut R>>, pinned projections of the inner variants.fn flip(self) -> Either<R, L>Convert
Either<L, R>toEither<R, L>.use *; let left: = Left; assert_eq!; let right: = Right; assert_eq!;fn map_left<F, M>(self, f: F) -> Either<M, R> where F: FnOnce(L) -> M,Apply the function
fon the value in theLeftvariant if it is present rewrapping the result inLeft.use *; let left: = Left; assert_eq!; let right: = Right; assert_eq!;fn map_right<F, S>(self, f: F) -> Either<L, S> where F: FnOnce(R) -> S,Apply the function
fon the value in theRightvariant if it is present rewrapping the result inRight.use *; let left: = Left; assert_eq!; let right: = Right; assert_eq!;fn map_left_or<F, S>(self, default: S, f: F) -> S where F: FnOnce(L) -> S,Returns the provided default (if
Right), or applies a function to the contained value (ifLeft).Examples
use *; let x: = Left; assert_eq!; let x: = Right; assert_eq!;fn map_right_or<F, S>(self, default: S, f: F) -> S where F: FnOnce(R) -> S,Returns the provided default (if
Left), or applies a function to the contained value (ifRight).Examples
use *; let x: = Left; assert_eq!; let x: = Right; assert_eq!;fn map_either<F, G, M, S>(self, f: F, g: G) -> Either<M, S> where F: FnOnce(L) -> M, G: FnOnce(R) -> S,Apply the functions
fandgto theLeftandRightvariants respectively. This is equivalent to bimap in functional programming.use *; let f = ; let g = ; let left: = Left; assert_eq!; let right: = Right; assert_eq!;fn map_either_with<Ctx, F, G, M, S>(self, ctx: Ctx, f: F, g: G) -> Either<M, S> where F: FnOnce(Ctx, L) -> M, G: FnOnce(Ctx, R) -> S,Similar to [
map_either][Self::map_either], with an added contextctxaccessible to both functions.use *; let mut sum = 0; // Both closures want to update the same value, so pass it as context. let mut f = ; let mut g = ; let left: = Left; assert_eq!; let right: = Right; assert_eq!; assert_eq!;fn either<F, G, T>(self, f: F, g: G) -> T where F: FnOnce(L) -> T, G: FnOnce(R) -> T,Apply one of two functions depending on contents, unifying their result. If the value is
Left(L)then the first functionfis applied; if it isRight(R)then the second functiongis applied.use *; let left: = Left; assert_eq!; let right: = Right; assert_eq!;fn either_with<Ctx, F, G, T>(self, ctx: Ctx, f: F, g: G) -> T where F: FnOnce(Ctx, L) -> T, G: FnOnce(Ctx, R) -> T,Like [
either][Self::either], but provide some context to whichever of the functions ends up being called.// In this example, the context is a mutable reference use *; let mut result = Vecnew; let values = vec!; for value in values assert_eq!;fn left_and<S>(self, other: Either<S, R>) -> Either<S, R>Returns
otherif the value isLeft, otherwise returns theRightvalue ofself.Arguments passed to
left_andare eagerly evaluated; if you are passing the result of a function call, it is recommended to useleft_and_then, which is lazily evaluated.Examples
use *; let left: = Left; assert_eq!; assert_eq!; let right: = Right; assert_eq!; assert_eq!;fn right_and<S>(self, other: Either<L, S>) -> Either<L, S>Returns
otherif the value isRight, otherwise returns theLeftvalue ofself.Arguments passed to
right_andare eagerly evaluated; if you are passing the result of a function call, it is recommended to useright_and_then, which is lazily evaluated.Examples
use *; let left: = Left; assert_eq!; assert_eq!; let right: = Right; assert_eq!; assert_eq!;fn left_and_then<F, S>(self, f: F) -> Either<S, R> where F: FnOnce(L) -> Either<S, R>,Apply the function
fon the value in theLeftvariant if it is present.use *; let left: = Left; assert_eq!; let right: = Right; assert_eq!;fn right_and_then<F, S>(self, f: F) -> Either<L, S> where F: FnOnce(R) -> Either<L, S>,Apply the function
fon the value in theRightvariant if it is present.use *; let left: = Left; assert_eq!; let right: = Right; assert_eq!;fn into_iter(self) -> Either<L::IntoIter, R::IntoIter> where L: IntoIterator, R: IntoIterator<Item = L::Item>,Convert the inner value to an iterator.
This requires the
LeftandRightiterators to have the same item type. See [factor_into_iter][Either::factor_into_iter] to iterate different types.use *; let left: = Left; let mut right: = Right; right.extend; assert_eq!;fn iter(&self) -> Either<<&L as IntoIterator>::IntoIter, <&R as IntoIterator>::IntoIter> where for<'a> &'a L: IntoIterator, for<'a> &'a R: IntoIterator<Item = <&'a L as IntoIterator>::Item>,Borrow the inner value as an iterator.
This requires the
LeftandRightiterators to have the same item type. See [factor_iter][Either::factor_iter] to iterate different types.use *; let left: = Left; let mut right: = Right; let mut all = vec!; all.extend; all.extend; assert_eq!;fn iter_mut(&mut self) -> Either<<&mut L as IntoIterator>::IntoIter, <&mut R as IntoIterator>::IntoIter> where for<'a> &'a mut L: IntoIterator, for<'a> &'a mut R: IntoIterator<Item = <&'a mut L as IntoIterator>::Item>,Mutably borrow the inner value as an iterator.
This requires the
LeftandRightiterators to have the same item type. See [factor_iter_mut][Either::factor_iter_mut] to iterate different types.use *; let mut left: = Left; for l in left.iter_mut assert_eq!; let mut inner = ; let mut right: = Right; for r in right.iter_mut assert_eq!;fn factor_into_iter(self) -> IterEither<L::IntoIter, R::IntoIter> where L: IntoIterator, R: IntoIterator,Converts an
EitherofIterators to be anIteratorofEithersUnlike [
into_iter][Either::into_iter], this does not require theLeftandRightiterators to have the same item type.use *; let left: = Left; assert_eq!; let right: = Right; assert_eq!;fn factor_iter(&self) -> IterEither<<&L as IntoIterator>::IntoIter, <&R as IntoIterator>::IntoIter> where for<'a> &'a L: IntoIterator, for<'a> &'a R: IntoIterator,Borrows an
EitherofIterators to be anIteratorofEithersUnlike [
iter][Either::iter], this does not require theLeftandRightiterators to have the same item type.use *; let left: = Left; assert_eq!; let right: = Right; assert_eq!;fn factor_iter_mut(&mut self) -> IterEither<<&mut L as IntoIterator>::IntoIter, <&mut R as IntoIterator>::IntoIter> where for<'a> &'a mut L: IntoIterator, for<'a> &'a mut R: IntoIterator,Mutably borrows an
EitherofIterators to be anIteratorofEithersUnlike [
iter_mut][Either::iter_mut], this does not require theLeftandRightiterators to have the same item type.use *; let mut left: = Left; left.factor_iter_mut.for_each; assert_eq!; let mut right: = Right; right.factor_iter_mut.for_each; assert_eq!;fn left_or(self, other: L) -> LReturn left value or given value
Arguments passed to
left_orare eagerly evaluated; if you are passing the result of a function call, it is recommended to use [left_or_else][Self::left_or_else], which is lazily evaluated.Examples
# use *; let left: = Left; assert_eq!; let right: = Right; assert_eq!;fn left_or_default(self) -> L where L: Default,Return left or a default
Examples
# use *; let left: = Left; assert_eq!; let right: = Right; assert_eq!;fn left_or_else<F>(self, f: F) -> L where F: FnOnce(R) -> L,Returns left value or computes it from a closure
Examples
# use *; let left: = Left; assert_eq!; let right: = Right; assert_eq!;fn right_or(self, other: R) -> RReturn right value or given value
Arguments passed to
right_orare eagerly evaluated; if you are passing the result of a function call, it is recommended to use [right_or_else][Self::right_or_else], which is lazily evaluated.Examples
# use *; let right: = Right; assert_eq!; let left: = Left; assert_eq!;fn right_or_default(self) -> R where R: Default,Return right or a default
Examples
# use *; let left: = Left; assert_eq!; let right: = Right; assert_eq!;fn right_or_else<F>(self, f: F) -> R where F: FnOnce(L) -> R,Returns right value or computes it from a closure
Examples
# use *; let left: = Left; assert_eq!; let right: = Right; assert_eq!;fn unwrap_left(self) -> L where R: Debug,Returns the left value
Examples
# use *; let left: = Left; assert_eq!;Panics
When
Eitheris aRightvalue# use either::*; let right: Either<(), _> = Right(3); right.unwrap_left();fn unwrap_right(self) -> R where L: Debug,Returns the right value
Examples
# use *; let right: = Right; assert_eq!;Panics
When
Eitheris aLeftvalue# use either::*; let left: Either<_, ()> = Left(3); left.unwrap_right();fn expect_left(self, msg: &str) -> L where R: Debug,Returns the left value
Examples
# use *; let left: = Left; assert_eq!;Panics
When
Eitheris aRightvalue# use either::*; let right: Either<(), _> = Right(3); right.expect_left("value was Right");fn expect_right(self, msg: &str) -> R where L: Debug,Returns the right value
Examples
# use *; let right: = Right; assert_eq!;Panics
When
Eitheris aLeftvalue# use either::*; let left: Either<_, ()> = Left(3); left.expect_right("value was Right");fn inspect_left<F>(self, f: F) -> Self where F: FnOnce(&L),Calls a function with a reference to the contained value if
Left.Returns the original self.
Examples
use *; # let x = foo .inspect_left .left_or;fn inspect_right<F>(self, f: F) -> Self where F: FnOnce(&R),Calls a function with a reference to the contained value if
Right.Returns the original self.
Examples
use *; # let x = foo .inspect_right .left_or;fn either_into<T>(self) -> T where L: Into<T>, R: Into<T>,Convert the contained value into
TExamples
# use *; // Both u16 and u32 can be converted to u64. let left: = Left; assert_eq!; let right: = Right; assert_eq!;
impl<L, R> Either<Option<L>, Option<R>>
fn factor_none(self) -> Option<Either<L, R>>Factors out
Nonefrom anEitherofOption.use *; let left: = Left; assert_eq!; let right: = Right; assert_eq!;
impl<L, R, E> Either<Result<L, E>, Result<R, E>>
impl<T> Either<T, T>
fn into_inner(self) -> TExtract the value of an either over two equivalent types.
use *; let left: = Left; assert_eq!; let right: = Right; assert_eq!;fn map<F, M>(self, f: F) -> Either<M, M> where F: FnOnce(T) -> M,Map
fover the contained value and return the result in the corresponding variant.use *; let value: = Right; let other = value.map; assert_eq!;
impl<T, L, R> Either<(L, T), (R, T)>
fn factor_second(self) -> (Either<L, R>, T)Factor out a homogeneous type from an either of pairs.
Here, the homogeneous type is the second element of the pairs.
use *; let left: = Left; assert_eq!; let right: = Right; assert_eq!;
impl<T, L, R> Either<(T, L), (T, R)>
fn factor_first(self) -> (T, Either<L, R>)Factor out a homogeneous type from an either of pairs.
Here, the homogeneous type is the first element of the pairs.
use *; let left: = Left; assert_eq!; let right: = Right; assert_eq!;
impl<T, L, R> Either<Result<T, L>, Result<T, R>>
Trait Implementations
impl<L, R> AsMut<CStr> for Either<L, R>
where
L: AsMut<CStr>,
R: AsMut<CStr>,
fn as_mut(&mut self) -> &mut CStr
impl<L, R> AsMut<OsStr> for Either<L, R>
where
L: AsMut<OsStr>,
R: AsMut<OsStr>,
fn as_mut(&mut self) -> &mut OsStr
impl<L, R> AsMut<Path> for Either<L, R>
where
L: AsMut<Path>,
R: AsMut<Path>,
fn as_mut(&mut self) -> &mut Path
impl<L, R> AsMut<str> for Either<L, R>
where
L: AsMut<str>,
R: AsMut<str>,
fn as_mut(&mut self) -> &mut str
impl<L, R> AsRef<CStr> for Either<L, R>
where
L: AsRef<CStr>,
R: AsRef<CStr>,
fn as_ref(&self) -> &CStr
impl<L, R> AsRef<OsStr> for Either<L, R>
where
L: AsRef<OsStr>,
R: AsRef<OsStr>,
fn as_ref(&self) -> &OsStr
impl<L, R> AsRef<Path> for Either<L, R>
where
L: AsRef<Path>,
R: AsRef<Path>,
fn as_ref(&self) -> &Path
impl<L, R> AsRef<str> for Either<L, R>
where
L: AsRef<str>,
R: AsRef<str>,
fn as_ref(&self) -> &str
impl<L, R> Binary for Either<L, R>
where
L: Binary,
R: Binary,
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<L, R> BufRead for Either<L, R>
where
L: BufRead,
R: BufRead,
fn fill_buf(&mut self) -> Result<&[u8]>fn consume(&mut self, amt: usize)fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<usize>fn read_line(&mut self, buf: &mut String) -> Result<usize>
impl<L, R> Deref for Either<L, R>
where
L: Deref,
R: Deref<Target = L::Target>,
type Target = <L as Deref>::Target;fn deref(&self) -> &Self::Target
impl<L, R> DerefMut for Either<L, R>
where
L: DerefMut,
R: DerefMut<Target = L::Target>,
fn deref_mut(&mut self) -> &mut Self::Target
impl<L, R> Display for Either<L, R>
where
L: Display,
R: Display,
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<L, R> DoubleEndedIterator for Either<L, R>
where
L: DoubleEndedIterator,
R: DoubleEndedIterator<Item = L::Item>,
fn next_back(&mut self) -> Option<Self::Item>fn nth_back(&mut self, n: usize) -> Option<Self::Item>fn rfold<Acc, G>(self, init: Acc, f: G) -> Acc where G: FnMut(Acc, Self::Item) -> Acc,fn rfind<P>(&mut self, predicate: P) -> Option<Self::Item> where P: FnMut(&Self::Item) -> bool,
impl<L, R> Error for Either<L, R>
where
L: Error,
R: Error,
fn source(&self) -> Option<&dyn Error + 'static>fn description(&self) -> &strfn cause(&self) -> Option<&dyn Error>
impl<L, R> ExactSizeIterator for Either<L, R>
where
L: ExactSizeIterator,
R: ExactSizeIterator<Item = L::Item>,
fn len(&self) -> usize
impl<L, R> From<Result<R, L>> for Either<L, R>
fn from(r: Result<R, L>) -> Self
impl<L, R> FusedIterator for Either<L, R>
where
L: FusedIterator,
R: FusedIterator<Item = L::Item>,
impl<L, R> Future for Either<L, R>
where
L: Future,
R: Future<Output = L::Output>,
type Output = <L as Future>::Output;fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>
impl<L, R> Iterator for Either<L, R>
where
L: Iterator,
R: Iterator<Item = L::Item>,
type Item = <L as Iterator>::Item;fn next(&mut self) -> Option<Self::Item>fn size_hint(&self) -> (usize, Option<usize>)fn fold<Acc, G>(self, init: Acc, f: G) -> Acc where G: FnMut(Acc, Self::Item) -> Acc,fn for_each<F>(self, f: F) where F: FnMut(Self::Item),fn count(self) -> usizefn last(self) -> Option<Self::Item>fn nth(&mut self, n: usize) -> Option<Self::Item>fn collect<B>(self) -> B where B: FromIterator<Self::Item>,fn partition<B, F>(self, f: F) -> (B, B) where B: Default + Extend<Self::Item>, F: FnMut(&Self::Item) -> bool,fn all<F>(&mut self, f: F) -> bool where F: FnMut(Self::Item) -> bool,fn any<F>(&mut self, f: F) -> bool where F: FnMut(Self::Item) -> bool,fn find<P>(&mut self, predicate: P) -> Option<Self::Item> where P: FnMut(&Self::Item) -> bool,fn find_map<B, F>(&mut self, f: F) -> Option<B> where F: FnMut(Self::Item) -> Option<B>,fn position<P>(&mut self, predicate: P) -> Option<usize> where P: FnMut(Self::Item) -> bool,
impl<L, R> LowerExp for Either<L, R>
where
L: LowerExp,
R: LowerExp,
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<L, R> LowerHex for Either<L, R>
where
L: LowerHex,
R: LowerHex,
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<L, R> Octal for Either<L, R>
where
L: Octal,
R: Octal,
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<L, R> Pointer for Either<L, R>
where
L: Pointer,
R: Pointer,
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<L, R> Read for Either<L, R>
where
L: Read,
R: Read,
fn read(&mut self, buf: &mut [u8]) -> Result<usize>fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>fn read_to_string(&mut self, buf: &mut String) -> Result<usize>
impl<L, R> Seek for Either<L, R>
where
L: Seek,
R: Seek,
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
impl<L, R> UpperExp for Either<L, R>
where
L: UpperExp,
R: UpperExp,
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<L, R> UpperHex for Either<L, R>
where
L: UpperHex,
R: UpperHex,
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<L, R> Write for Either<L, R>
where
L: Write,
R: Write,
fn write(&mut self, buf: &[u8]) -> Result<usize>fn write_all(&mut self, buf: &[u8]) -> Result<()>fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<()>fn flush(&mut self) -> Result<()>
impl<L, R> Write for Either<L, R>
where
L: Write,
R: Write,
fn write_str(&mut self, s: &str) -> Resultfn write_char(&mut self, c: char) -> Resultfn write_fmt(&mut self, args: Arguments<'_>) -> Result
impl<L, R, A> Extend<A> for Either<L, R>
where
L: Extend<A>,
R: Extend<A>,
fn extend<T>(&mut self, iter: T) where T: IntoIterator<Item = A>,
impl<L, R, Target> AsMut<Target> for Either<L, R>
where
L: AsMut<Target>,
R: AsMut<Target>,
fn as_mut(&mut self) -> &mut Target
impl<L, R, Target> AsMut<[Target]> for Either<L, R>
where
L: AsMut<[Target]>,
R: AsMut<[Target]>,
fn as_mut(&mut self) -> &mut [Target]
impl<L, R, Target> AsRef<Target> for Either<L, R>
where
L: AsRef<Target>,
R: AsRef<Target>,
fn as_ref(&self) -> &Target
impl<L, R, Target> AsRef<[Target]> for Either<L, R>
where
L: AsRef<[Target]>,
R: AsRef<[Target]>,
fn as_ref(&self) -> &[Target]
impl<L: Clone, R: Clone> Clone for Either<L, R>
fn clone(&self) -> Selffn clone_from(&mut self, source: &Self)
impl<L: Copy, R: Copy> Copy for Either<L, R>
impl<L: Debug, R: Debug> Debug for Either<L, R>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<L: Eq, R: Eq> Eq for Either<L, R>
impl<L: Hash, R: Hash> Hash for Either<L, R>
fn hash<__H: Hasher>(&self, state: &mut __H)
impl<L: Ord, R: Ord> Ord for Either<L, R>
fn cmp(&self, other: &Self) -> Ordering
impl<L: PartialEq, R: PartialEq> PartialEq for Either<L, R>
fn eq(&self, other: &Self) -> bool
impl<L: PartialEq, R: PartialEq> StructuralPartialEq for Either<L, R>
impl<L: PartialOrd, R: PartialOrd> PartialOrd for Either<L, R>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
Auto Trait Implementations
impl<L, R> Freeze for Either<L, R>
where
L: Freeze,
R: Freeze,
impl<L, R> RefUnwindSafe for Either<L, R>
where
L: RefUnwindSafe,
R: RefUnwindSafe,
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
impl<F> IntoFuture for Either<L, R>
where
F: Future,
type Output = <F as Future>::Output;type IntoFuture = F;fn into_future(self) -> <F as IntoFuture>::IntoFuture
impl<I> IntoIterator for Either<L, R>
where
I: Iterator,
type Item = <I as Iterator>::Item;type IntoIter = I;fn into_iter(self) -> I
impl<P, T> Receiver for Either<L, R>
where
P: Deref<Target = T> + ?Sized,
T: ?Sized,
type Target = T;
impl<T> Any for Either<L, R>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Either<L, R>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Either<L, R>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Either<L, R>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Either<L, R>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> IntoEither for Either<L, R>
impl<T> ToOwned for Either<L, R>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T> ToString for Either<L, R>
where
T: Display + ?Sized,
fn to_string(&self) -> String
impl<T, U> Into<U> for Either<L, R>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Either<L, R>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Either<L, R>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>