Enum futures_util::future::Either [−][src]
pub enum Either<A, B> {
Left(A),
Right(B),
}
Expand description
Combines two different futures, streams, or sinks having the same associated types into a single type.
This is useful when conditionally choosing between two distinct future types:
use futures::future::Either;
let cond = true;
let fut = if cond {
Either::Left(async move { 12 })
} else {
Either::Right(async move { 44 })
};
assert_eq!(fut.await, 12);
Variants
First branch of the type
Second branch of the type
Implementations
Factor out a homogeneous type from an either of pairs.
Here, the homogeneous type is the first element of the pairs.
Factor out a homogeneous type from an either of pairs.
Here, the homogeneous type is the second element of the pairs.
Extract the value of an either over two equivalent types.
Trait Implementations
impl<A, B> FusedFuture for Either<A, B> where
A: FusedFuture,
B: FusedFuture<Output = A::Output>,
impl<A, B> FusedFuture for Either<A, B> where
A: FusedFuture,
B: FusedFuture<Output = A::Output>,
Returns true
if the underlying future should no longer be polled.
Returns true
if the stream should no longer be polled.
Attempt to pull out the next value of this stream, registering the
current task for wakeup if the value is not yet available, and returning
None
if the stream is exhausted. Read more
Auto Trait Implementations
impl<A, B> RefUnwindSafe for Either<A, B> where
A: RefUnwindSafe,
B: RefUnwindSafe,
impl<A, B> UnwindSafe for Either<A, B> where
A: UnwindSafe,
B: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
into_future
)The output that the future will produce on completion.
type Future = F
type Future = F
into_future
)Which kind of future are we turning this into?
into_future
)Creates a future from a value.