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 either::*; let values = [Left(1), Right("the right value")]; assert_eq!(values[0].is_left(), true); assert_eq!(values[1].is_left(), false);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 either::*; let left0: Either<i32, i32> = Left(0); let left2: Either<i32, i32> = Left(2); let right: Either<i32, i32> = Right(2); assert_eq!(left2.is_left_and(|n| n > 1), true); assert_eq!(left0.is_left_and(|n| n > 1), false); assert_eq!(right.is_left_and(|n| n > 1), false);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 either::*; let right0: Either<i32, i32> = Right(0); let right2: Either<i32, i32> = Right(2); let left: Either<i32, i32> = Left(2); assert_eq!(right2.is_right_and(|n| n > 1), true); assert_eq!(right0.is_right_and(|n| n > 1), false); assert_eq!(left.is_right_and(|n| n > 1), false);fn is_left_or<F>(self, f: F) -> bool where F: FnOnce(R) -> bool,Returns
trueif the value isLeft, or value isRightand the value inside of it matches a predicate.Examples
use either::*; let left: Either<i32, i32> = Left(0); let right2: Either<i32, i32> = Right(2); let right0: Either<i32, i32> = Right(0); assert_eq!(left.is_left_or(|n| n > 1), true); assert_eq!(right2.is_left_or(|n| n > 1), true); assert_eq!(right0.is_left_or(|n| n > 1), false);fn is_right_or<F>(self, f: F) -> bool where F: FnOnce(L) -> bool,Returns
trueif the value isRight, or value isLeftand the value inside of it matches a predicate.Examples
use either::*; let right: Either<i32, i32> = Right(0); let left2: Either<i32, i32> = Left(2); let left0: Either<i32, i32> = Left(0); assert_eq!(right.is_right_or(|n| n > 1), true); assert_eq!(left2.is_right_or(|n| n > 1), true); assert_eq!(left0.is_right_or(|n| n > 1), false);fn is_right(&self) -> boolReturn true if the value is the
Rightvariant.use either::*; let values = [Left(1), Right("the right value")]; assert_eq!(values[0].is_right(), false); assert_eq!(values[1].is_right(), true);fn left(self) -> Option<L>Convert the left side of
Either<L, R>to anOption<L>.use either::*; let left: Either<_, ()> = Left("some value"); assert_eq!(left.left(), Some("some value")); let right: Either<(), _> = Right(321); assert_eq!(right.left(), None);fn right(self) -> Option<R>Convert the right side of
Either<L, R>to anOption<R>.use either::*; let left: Either<_, ()> = Left("some value"); assert_eq!(left.right(), None); let right: Either<(), _> = Right(321); assert_eq!(right.right(), Some(321));fn as_ref(&self) -> Either<&L, &R>Convert
&Either<L, R>toEither<&L, &R>.use either::*; let left: Either<_, ()> = Left("some value"); assert_eq!(left.as_ref(), Left(&"some value")); let right: Either<(), _> = Right("some value"); assert_eq!(right.as_ref(), Right(&"some value"));fn as_mut(&mut self) -> Either<&mut L, &mut R>Convert
&mut Either<L, R>toEither<&mut L, &mut R>.use either::*; fn mutate_left(value: &mut Either<u32, u32>) { if let Some(l) = value.as_mut().left() { *l = 999; } } let mut left = Left(123); let mut right = Right(123); mutate_left(&mut left); mutate_left(&mut right); assert_eq!(left, Left(999)); assert_eq!(right, Right(123));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 either::*; let left: Either<_, ()> = Left(123); assert_eq!(left.flip(), Right(123)); let right: Either<(), _> = Right("some value"); assert_eq!(right.flip(), Left("some value"));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 either::*; let left: Either<_, u32> = Left(123); assert_eq!(left.map_left(|x| x * 2), Left(246)); let right: Either<u32, _> = Right(123); assert_eq!(right.map_left(|x| x * 2), Right(123));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 either::*; let left: Either<_, u32> = Left(123); assert_eq!(left.map_right(|x| x * 2), Left(123)); let right: Either<u32, _> = Right(123); assert_eq!(right.map_right(|x| x * 2), Right(246));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 either::*; let x: Either<_, i32> = Left(123); assert_eq!(x.map_left_or(0, |n| n * 2), 246); let x: Either<i32, _> = Right(123); assert_eq!(x.map_left_or(0, |n| n * 2), 0);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 either::*; let x: Either<_, i32> = Left(123); assert_eq!(x.map_right_or(0, |n| n * 2), 0); let x: Either<i32, _> = Right(123); assert_eq!(x.map_right_or(0, |n| n * 2), 246);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 either::*; let f = |s: String| s.len(); let g = |u: u8| u.to_string(); let left: Either<String, u8> = Left("loopy".into()); assert_eq!(left.map_either(f, g), Left(5)); let right: Either<String, u8> = Right(42); assert_eq!(right.map_either(f, g), Right("42".into()));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 either::*; let mut sum = 0; // Both closures want to update the same value, so pass it as context. let mut f = |sum: &mut usize, s: String| { *sum += s.len(); s.to_uppercase() }; let mut g = |sum: &mut usize, u: usize| { *sum += u; u.to_string() }; let left: Either<String, usize> = Left("loopy".into()); assert_eq!(left.map_either_with(&mut sum, &mut f, &mut g), Left("LOOPY".into())); let right: Either<String, usize> = Right(42); assert_eq!(right.map_either_with(&mut sum, &mut f, &mut g), Right("42".into())); assert_eq!(sum, 47);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 either::*; fn square(n: u32) -> i32 { (n * n) as i32 } fn negate(n: i32) -> i32 { -n } let left: Either<u32, i32> = Left(4); assert_eq!(left.either(square, negate), 16); let right: Either<u32, i32> = Right(-4); assert_eq!(right.either(square, negate), 4);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 either::*; let mut result = Vec::new(); let values = vec![Left(2), Right(2.7)]; for value in values { value.either_with(&mut result, |ctx, integer| ctx.push(integer), |ctx, real| ctx.push(f64::round(real) as i32)); } assert_eq!(result, vec![2, 3]);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 either::*; let left: Either<_, u32> = Left(123); assert_eq!(left.left_and::<()>(Right(246)), Right(246)); assert_eq!(left.left_and(Left(246)), Left(246)); let right: Either<u32, _> = Right(123); assert_eq!(right.left_and::<()>(Right(246)), Right(123)); assert_eq!(right.left_and(Left(246)), Right(123));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 either::*; let left: Either<_, u32> = Left(123); assert_eq!(left.right_and(Right(246)), Left(123)); assert_eq!(left.right_and::<()>(Left(246)), Left(123)); let right: Either<u32, _> = Right(123); assert_eq!(right.right_and(Right(246)), Right(246)); assert_eq!(right.right_and::<()>(Left(246)), Left(246));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 either::*; let left: Either<_, u32> = Left(123); assert_eq!(left.left_and_then::<_,()>(|x| Right(x * 2)), Right(246)); let right: Either<u32, _> = Right(123); assert_eq!(right.left_and_then(|x| Right::<(), _>(x * 2)), Right(123));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 either::*; let left: Either<_, u32> = Left(123); assert_eq!(left.right_and_then(|x| Right(x * 2)), Left(123)); let right: Either<u32, _> = Right(123); assert_eq!(right.right_and_then(|x| Right(x * 2)), Right(246));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 either::*; let left: Either<_, Vec<u32>> = Left(vec![1, 2, 3, 4, 5]); let mut right: Either<Vec<u32>, _> = Right(vec![]); right.extend(left.into_iter()); assert_eq!(right, Right(vec![1, 2, 3, 4, 5]));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 either::*; let left: Either<_, &[u32]> = Left(vec![2, 3]); let mut right: Either<Vec<u32>, _> = Right(&[4, 5][..]); let mut all = vec![1]; all.extend(left.iter()); all.extend(right.iter()); assert_eq!(all, vec![1, 2, 3, 4, 5]);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 either::*; let mut left: Either<_, &mut [u32]> = Left(vec![2, 3]); for l in left.iter_mut() { *l *= *l } assert_eq!(left, Left(vec![4, 9])); let mut inner = [4, 5]; let mut right: Either<Vec<u32>, _> = Right(&mut inner[..]); for r in right.iter_mut() { *r *= *r } assert_eq!(inner, [16, 25]);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 either::*; let left: Either<_, Vec<u8>> = Left(&["hello"]); assert_eq!(left.factor_into_iter().next(), Some(Left(&"hello"))); let right: Either<&[&str], _> = Right(vec![0, 1]); assert_eq!(right.factor_into_iter().collect::<Vec<_>>(), vec![Right(0), Right(1)]);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 either::*; let left: Either<_, Vec<u8>> = Left(["hello"]); assert_eq!(left.factor_iter().next(), Some(Left(&"hello"))); let right: Either<[&str; 2], _> = Right(vec![0, 1]); assert_eq!(right.factor_iter().collect::<Vec<_>>(), vec![Right(&0), Right(&1)]);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 either::*; let mut left: Either<_, Vec<u8>> = Left(["hello"]); left.factor_iter_mut().for_each(|x| *x.unwrap_left() = "goodbye"); assert_eq!(left, Left(["goodbye"])); let mut right: Either<[&str; 2], _> = Right(vec![0, 1, 2]); right.factor_iter_mut().for_each(|x| if let Right(r) = x { *r = -*r; }); assert_eq!(right, Right(vec![0, -1, -2]));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 either::*; let left: Either<&str, &str> = Left("left"); assert_eq!(left.left_or("foo"), "left"); let right: Either<&str, &str> = Right("right"); assert_eq!(right.left_or("left"), "left");fn left_or_default(self) -> L where L: Default,Return left or a default
Examples
# use either::*; let left: Either<String, u32> = Left("left".to_string()); assert_eq!(left.left_or_default(), "left"); let right: Either<String, u32> = Right(42); assert_eq!(right.left_or_default(), String::default());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 either::*; let left: Either<String, u32> = Left("3".to_string()); assert_eq!(left.left_or_else(|_| unreachable!()), "3"); let right: Either<String, u32> = Right(3); assert_eq!(right.left_or_else(|x| x.to_string()), "3");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 either::*; let right: Either<&str, &str> = Right("right"); assert_eq!(right.right_or("foo"), "right"); let left: Either<&str, &str> = Left("left"); assert_eq!(left.right_or("right"), "right");fn right_or_default(self) -> R where R: Default,Return right or a default
Examples
# use either::*; let left: Either<String, u32> = Left("left".to_string()); assert_eq!(left.right_or_default(), u32::default()); let right: Either<String, u32> = Right(42); assert_eq!(right.right_or_default(), 42);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 either::*; let left: Either<String, u32> = Left("3".to_string()); assert_eq!(left.right_or_else(|x| x.parse().unwrap()), 3); let right: Either<String, u32> = Right(3); assert_eq!(right.right_or_else(|_| unreachable!()), 3);fn unwrap_left(self) -> L where R: Debug,Returns the left value
Examples
# use either::*; let left: Either<_, ()> = Left(3); assert_eq!(left.unwrap_left(), 3);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 either::*; let right: Either<(), _> = Right(3); assert_eq!(right.unwrap_right(), 3);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 either::*; let left: Either<_, ()> = Left(3); assert_eq!(left.expect_left("value was Right"), 3);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 either::*; let right: Either<(), _> = Right(3); assert_eq!(right.expect_right("value was Left"), 3);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 either::*; # fn foo() -> Either<u32, u32> { Right(2) } let x = foo() .inspect_left(|n| println!("left: {n}")) .left_or(0);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 either::*; # fn foo() -> Either<u32, u32> { Right(2) } let x = foo() .inspect_right(|n| println!("right: {n}")) .left_or(0);fn either_into<T>(self) -> T where L: Into<T>, R: Into<T>,Convert the contained value into
TExamples
# use either::*; // Both u16 and u32 can be converted to u64. let left: Either<u16, u32> = Left(3u16); assert_eq!(left.either_into::<u64>(), 3u64); let right: Either<u16, u32> = Right(7u32); assert_eq!(right.either_into::<u64>(), 7u64);
impl<L, R> Either<Option<L>, Option<R>>
fn factor_none(self) -> Option<Either<L, R>>Factors out
Nonefrom anEitherofOption.use either::*; let left: Either<_, Option<String>> = Left(Some(vec![0])); assert_eq!(left.factor_none(), Some(Left(vec![0]))); let right: Either<Option<Vec<u8>>, _> = Right(Some(String::new())); assert_eq!(right.factor_none(), Some(Right(String::new())));
impl<L, R, E> Either<Result<L, E>, Result<R, E>>
fn factor_err(self) -> Result<Either<L, R>, E>Factors out a homogeneous type from an
EitherofResult.Here, the homogeneous type is the
Errtype of theResult.use either::*; let left: Either<_, Result<String, u32>> = Left(Ok(vec![0])); assert_eq!(left.factor_err(), Ok(Left(vec![0]))); let right: Either<Result<Vec<u8>, u32>, _> = Right(Ok(String::new())); assert_eq!(right.factor_err(), Ok(Right(String::new())));
impl<T> Either<T, T>
fn into_inner(self) -> TExtract the value of an either over two equivalent types.
use either::*; let left: Either<_, u32> = Left(123); assert_eq!(left.into_inner(), 123); let right: Either<u32, _> = Right(123); assert_eq!(right.into_inner(), 123);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 either::*; let value: Either<_, i32> = Right(42); let other = value.map(|x| x * 2); assert_eq!(other, Right(84));
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 either::*; let left: Either<_, (String, u32)> = Left((vec![0], 123)); assert_eq!(left.factor_second().1, 123); let right: Either<(Vec<u8>, u32), _> = Right((String::new(), 123)); assert_eq!(right.factor_second().1, 123);
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 either::*; let left: Either<_, (u32, String)> = Left((123, vec![0])); assert_eq!(left.factor_first().0, 123); let right: Either<(u32, Vec<u8>), _> = Right((123, String::new())); assert_eq!(right.factor_first().0, 123);
impl<T, L, R> Either<Result<T, L>, Result<T, R>>
fn factor_ok(self) -> Result<T, Either<L, R>>Factors out a homogeneous type from an
EitherofResult.Here, the homogeneous type is the
Oktype of theResult.use either::*; let left: Either<_, Result<u32, String>> = Left(Err(vec![0])); assert_eq!(left.factor_ok(), Err(Left(vec![0]))); let right: Either<Result<u32, Vec<u8>>, _> = Right(Err(String::new())); assert_eq!(right.factor_ok(), Err(Right(String::new())));
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>