Sha256: d966bde7b06a88443f0efd877e95f91541778c4e713f3f4b66e00ca5d3f352b6

Contents?: true

Size: 939 Bytes

Versions: 26

Compression:

Stored size: 939 Bytes

Contents

use core::pin::Pin;
use futures_core::future::{FusedFuture, Future, TryFuture};
use futures_core::task::{Context, Poll};
use pin_project_lite::pin_project;

pin_project! {
    /// Future for the [`into_future`](super::TryFutureExt::into_future) method.
    #[derive(Debug)]
    #[must_use = "futures do nothing unless you `.await` or poll them"]
    pub struct IntoFuture<Fut> {
        #[pin]
        future: Fut,
    }
}

impl<Fut> IntoFuture<Fut> {
    #[inline]
    pub(crate) fn new(future: Fut) -> Self {
        Self { future }
    }
}

impl<Fut: TryFuture + FusedFuture> FusedFuture for IntoFuture<Fut> {
    fn is_terminated(&self) -> bool {
        self.future.is_terminated()
    }
}

impl<Fut: TryFuture> Future for IntoFuture<Fut> {
    type Output = Result<Fut::Ok, Fut::Error>;

    #[inline]
    fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
        self.project().future.try_poll(cx)
    }
}

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
wasmtime-14.0.3 ./ext/cargo-vendor/futures-util-0.3.28/src/future/try_future/into_future.rs
wasmtime-14.0.1 ./ext/cargo-vendor/futures-util-0.3.28/src/future/try_future/into_future.rs
wasmtime-14.0.0 ./ext/cargo-vendor/futures-util-0.3.28/src/future/try_future/into_future.rs
wasmtime-13.0.0 ./ext/cargo-vendor/futures-util-0.3.28/src/future/try_future/into_future.rs
wasmtime-12.0.1 ./ext/cargo-vendor/futures-util-0.3.28/src/future/try_future/into_future.rs
wasmtime-12.0.0 ./ext/cargo-vendor/futures-util-0.3.28/src/future/try_future/into_future.rs