[][src]Struct dyn_future::DynFuture

#[must_use = "futures do nothing unless polled"]
pub struct DynFuture<T: 'static> { /* fields omitted */ }

Represents an asyncronous computation.

This is different from std::future::Future in that it is a fixed size struct with a boxed future inside.

Using this is advantageous over Box<dyn Future<Output = T>> due to less overhead.

Methods

impl<T> DynFuture<T>[src]

pub fn new(f: impl Future<Output = T> + Send + 'static) -> Pin<Self>[src]

Creates a new DynFuture from a std::future::Future.

This method may but rarely calls the global allocator. Almost all allocations occur via a fast path using a bump allocator.

pub fn into_boxed(self) -> Pin<Box<dyn Future<Output = T> + Send>>[src]

Converts a DynFuture<T> into a Box<dyn Future<Output = T> + Send>.

pub fn from_boxed(boxed: Pin<Box<dyn Future<Output = T> + Send>>) -> Pin<Self>[src]

Converts a Box<dyn Future<Output = T> + Send> into a DynFuture<T>.

Trait Implementations

impl<T> Send for DynFuture<T>[src]

impl<T> Drop for DynFuture<T>[src]

impl<T> Deref for DynFuture<T>[src]

type Target = dyn Future<Output = T> + Send

The resulting type after dereferencing.

impl<T> DerefMut for DynFuture<T>[src]

impl<T> Future for DynFuture<T>[src]

type Output = T

The type of value produced on completion.

Auto Trait Implementations

impl<T> !Sync for DynFuture<T>

impl<T> Unpin for DynFuture<T>

impl<T> !UnwindSafe for DynFuture<T>

impl<T> !RefUnwindSafe for DynFuture<T>

Blanket Implementations

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

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

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

type Error = !

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> Borrow<T> for T where
    T: ?Sized
[src]

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

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