ready

Description

readcy[fn:documentation] creates a future that is immediately ready with a value.

Futures created through this function are functionally similar to those created through async {}. The main difference is that futures created through this function are named and implement Unpin.

Declaration

pub fn ready() -> Ready

Notable traits

impl Future for Ready
type Output = T;

Examples

use core::future;

let a = future::ready(1);
assert_eq!(a.await, 1);

Footnotes

[fn:documentation]https://doc.rust-lang.org/std/future/fn.pending.html