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 moreimpl<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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)