pub trait FutureExt: Future + Sized {
// Provided methods
fn discard(self) -> Discard<Self> { ... }
fn boxify(self) -> BoxFuture<Self::Item, Self::Error>
where Self: 'static + Send { ... }
fn boxify_nonsend(self) -> BoxFutureNonSend<Self::Item, Self::Error>
where Self: 'static { ... }
fn left_future<B>(self) -> Either<Self, B> { ... }
fn right_future<A>(self) -> Either<A, Self> { ... }
fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
where F: FnOnce(&Self::Error),
Self: Sized { ... }
fn inspect_result<F>(self, f: F) -> InspectResult<Self, F>
where F: FnOnce(Result<&Self::Item, &Self::Error>),
Self: Sized { ... }
}Expand description
A trait implemented by default for all Futures which extends the standard functionality.
Provided Methods§
Sourcefn discard(self) -> Discard<Self>
fn discard(self) -> Discard<Self>
Map a Future to have Item=() and Error=(). This is
useful when a future is being used to drive a computation
but the actual results aren’t interesting (such as when used
with Handle::spawn()).
Sourcefn boxify(self) -> BoxFuture<Self::Item, Self::Error>where
Self: 'static + Send,
fn boxify(self) -> BoxFuture<Self::Item, Self::Error>where
Self: 'static + Send,
Create a Sendable boxed version of this Future.
Sourcefn boxify_nonsend(self) -> BoxFutureNonSend<Self::Item, Self::Error>where
Self: 'static,
fn boxify_nonsend(self) -> BoxFutureNonSend<Self::Item, Self::Error>where
Self: 'static,
Create a non-Sendable boxed version of this Future.
Sourcefn left_future<B>(self) -> Either<Self, B>
fn left_future<B>(self) -> Either<Self, B>
Shorthand for returning future::Either::A
Sourcefn right_future<A>(self) -> Either<A, Self>
fn right_future<A>(self) -> Either<A, Self>
Shorthand for returning future::Either::B
Sourcefn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
Similar to future::Future::inspect, but runs the function on error
Sourcefn inspect_result<F>(self, f: F) -> InspectResult<Self, F>
fn inspect_result<F>(self, f: F) -> InspectResult<Self, F>
Similar to future::Future::inspect, but runs the function on both
output or error of the Future treating it as a regular Result
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.