Enum itertools::EitherOrBoth
source · pub enum EitherOrBoth<A, B> {
Both(A, B),
Left(A),
Right(B),
}
Expand description
Value that either holds a single A or B, or both.
Variants§
Both(A, B)
Both values are present.
Left(A)
Only the left value of type A
is present.
Right(B)
Only the right value of type B
is present.
Implementations§
source§impl<A, B> EitherOrBoth<A, B>
impl<A, B> EitherOrBoth<A, B>
sourcepub fn left(self) -> Option<A>
pub fn left(self) -> Option<A>
If Left
, or Both
, return Some
with the left value, otherwise, return None
.
sourcepub fn right(self) -> Option<B>
pub fn right(self) -> Option<B>
If Right
, or Both
, return Some
with the right value, otherwise, return None
.
sourcepub fn as_ref(&self) -> EitherOrBoth<&A, &B>
pub fn as_ref(&self) -> EitherOrBoth<&A, &B>
Converts from &EitherOrBoth<A, B>
to EitherOrBoth<&A, &B>
.
sourcepub fn as_mut(&mut self) -> EitherOrBoth<&mut A, &mut B>
pub fn as_mut(&mut self) -> EitherOrBoth<&mut A, &mut B>
Converts from &mut EitherOrBoth<A, B>
to EitherOrBoth<&mut A, &mut B>
.
Trait Implementations§
source§impl<A: Clone, B: Clone> Clone for EitherOrBoth<A, B>
impl<A: Clone, B: Clone> Clone for EitherOrBoth<A, B>
source§fn clone(&self) -> EitherOrBoth<A, B>
fn clone(&self) -> EitherOrBoth<A, B>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<A: PartialEq, B: PartialEq> PartialEq for EitherOrBoth<A, B>
impl<A: PartialEq, B: PartialEq> PartialEq for EitherOrBoth<A, B>
source§fn eq(&self, other: &EitherOrBoth<A, B>) -> bool
fn eq(&self, other: &EitherOrBoth<A, B>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl<A: Eq, B: Eq> Eq for EitherOrBoth<A, B>
impl<A, B> StructuralPartialEq for EitherOrBoth<A, B>
Auto Trait Implementations§
impl<A, B> Freeze for EitherOrBoth<A, B>
impl<A, B> RefUnwindSafe for EitherOrBoth<A, B>where
A: RefUnwindSafe,
B: RefUnwindSafe,
impl<A, B> Send for EitherOrBoth<A, B>
impl<A, B> Sync for EitherOrBoth<A, B>
impl<A, B> Unpin for EitherOrBoth<A, B>
impl<A, B> UnwindSafe for EitherOrBoth<A, B>where
A: UnwindSafe,
B: 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,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)