[][src]Struct either_future::EitherFuture

pub struct EitherFuture<LeftFuture, RightFuture>(_);

Methods

impl<LeftFuture, RightFuture> EitherFuture<LeftFuture, RightFuture>[src]

pub fn left(left_future: LeftFuture) -> Self[src]

pub fn right(right_future: RightFuture) -> Self[src]

Methods from Deref<Target = Either<LeftFuture, RightFuture>>

pub fn is_left(&self) -> bool[src]

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);

pub fn is_right(&self) -> bool[src]

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);

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

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"));

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

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

impl<LeftFuture, RightFuture> From<Either<LeftFuture, RightFuture>> for EitherFuture<LeftFuture, RightFuture>[src]

impl<LeftFuture, RightFuture> DerefMut for EitherFuture<LeftFuture, RightFuture>[src]

impl<LeftFuture, RightFuture> Deref for EitherFuture<LeftFuture, RightFuture>[src]

type Target = Either<LeftFuture, RightFuture>

The resulting type after dereferencing.

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

type Output = Either<Left, Right>

The type of value produced on completion.

impl<Left, Right, ErrorType, LeftFuture, RightFuture> Future for EitherFuture<LeftFuture, RightFuture> where
    LeftFuture: Future<Item = Left, Error = ErrorType>,
    RightFuture: Future<Item = Right, Error = ErrorType>, 
[src]

type Item = Either<Left, Right>

The type of value that this future will resolved with if it is successful. Read more

type Error = ErrorType

The type of error that this future will resolve with if it fails in a normal fashion. Read more

Auto Trait Implementations

impl<LeftFuture, RightFuture> Send for EitherFuture<LeftFuture, RightFuture> where
    LeftFuture: Send,
    RightFuture: Send

impl<LeftFuture, RightFuture> Unpin for EitherFuture<LeftFuture, RightFuture> where
    LeftFuture: Unpin,
    RightFuture: Unpin

impl<LeftFuture, RightFuture> Sync for EitherFuture<LeftFuture, RightFuture> where
    LeftFuture: Sync,
    RightFuture: Sync

impl<LeftFuture, RightFuture> UnwindSafe for EitherFuture<LeftFuture, RightFuture> where
    LeftFuture: UnwindSafe,
    RightFuture: UnwindSafe

impl<LeftFuture, RightFuture> RefUnwindSafe for EitherFuture<LeftFuture, RightFuture> where
    LeftFuture: RefUnwindSafe,
    RightFuture: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<F> IntoFuture for F where
    F: Future
[src]

type Future = F

The future that this type can be converted into.

type Item = <F as Future>::Item

The item that the future may resolve with.

type Error = <F as Future>::Error

The error that the future may resolve with.