[][src]Trait async_std::future::IntoFuture

pub trait IntoFuture {
    type Output;
    type Future: Future<Output = Self::Output>;
    fn into_future(self) -> Self::Future;
}
This is supported on unstable only.

Convert a type into a Future.

Examples

use async_std::future::{Future, IntoFuture};
use async_std::io;
use async_std::pin::Pin;

struct Client;

impl Client {
    pub async fn send(self) -> io::Result<()> {
        // Send a request
        Ok(())
    }
}

impl IntoFuture for Client {
    type Output = io::Result<()>;

    type Future = Pin<Box<dyn Future<Output = Self::Output>>>;

    fn into_future(self) -> Self::Future {
        Box::pin(async {
            self.send().await
        })
    }
}

Associated Types

type Output

This is supported on unstable only.

The type of value produced on completion.

type Future: Future<Output = Self::Output>

This is supported on unstable only.

Which kind of future are we turning this into?

Loading content...

Required methods

fn into_future(self) -> Self::Future

This is supported on unstable only.

Create a future from a value

Loading content...

Implementors

impl<T: Future> IntoFuture for T[src]

type Output = T::Output

This is supported on unstable and unstable only.

type Future = T

This is supported on unstable and unstable only.
Loading content...