Struct EitherFuture

Source
pub struct EitherFuture<Left, Right>(pub Either<Left, Right>);

Tuple Fields§

§0: Either<Left, Right>

Implementations§

Source§

impl<Left, Right> EitherFuture<Left, Right>

Source

pub fn left(left_future: Left) -> Self

Source

pub fn right(right_future: Right) -> Self

Methods from Deref<Target = Either<Left, Right>>§

Source

pub fn is_left(&self) -> bool

Return true if the value is the Left variant.

use either::*;

let values = [Left(1), Right("the right value")];
assert_eq!(values[0].is_left(), true);
assert_eq!(values[1].is_left(), false);
Source

pub fn is_right(&self) -> bool

Return true if the value is the Right variant.

use either::*;

let values = [Left(1), Right("the right value")];
assert_eq!(values[0].is_right(), false);
assert_eq!(values[1].is_right(), true);
Source

pub fn as_ref(&self) -> Either<&L, &R>

Convert &Either<L, R> to Either<&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"));
Source

pub fn as_mut(&mut self) -> Either<&mut L, &mut R>

Convert &mut Either<L, R> to Either<&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));

Trait Implementations§

Source§

impl<Left, Right> Deref for EitherFuture<Left, Right>

Source§

type Target = Either<Left, Right>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<Left, Right> DerefMut for EitherFuture<Left, Right>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<Left, Right> From<Either<Left, Right>> for EitherFuture<Left, Right>

Source§

fn from(either: Either<Left, Right>) -> Self

Converts to this type from the input type.
Source§

impl<Left, Right> From<EitherFuture<Left, Right>> for Either<Left, Right>

Source§

fn from(either_future: EitherFuture<Left, Right>) -> Either<Left, Right>

Converts to this type from the input type.
Source§

impl<Left, Right, LeftFuture, RightFuture> Future for EitherFuture<LeftFuture, RightFuture>
where LeftFuture: Future<Output = Left>, RightFuture: Future<Output = Right>,

Source§

type Output = Either<Left, Right>

The type of value produced on completion.
Source§

fn poll(self: Pin<&mut Self>, context: &mut Context<'_>) -> Poll<Self::Output>

Attempts to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more

Auto Trait Implementations§

§

impl<Left, Right> Freeze for EitherFuture<Left, Right>
where Left: Freeze, Right: Freeze,

§

impl<Left, Right> RefUnwindSafe for EitherFuture<Left, Right>
where Left: RefUnwindSafe, Right: RefUnwindSafe,

§

impl<Left, Right> Send for EitherFuture<Left, Right>
where Left: Send, Right: Send,

§

impl<Left, Right> Sync for EitherFuture<Left, Right>
where Left: Sync, Right: Sync,

§

impl<Left, Right> Unpin for EitherFuture<Left, Right>
where Left: Unpin, Right: Unpin,

§

impl<Left, Right> UnwindSafe for EitherFuture<Left, Right>
where Left: UnwindSafe, Right: 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> 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<F> IntoFuture for F
where F: Future,

Source§

type Output = <F as Future>::Output

The output that the future will produce on completion.
Source§

type IntoFuture = F

Which kind of future are we turning this into?
Source§

fn into_future(self) -> <F as IntoFuture>::IntoFuture

Creates a future from a value. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.