Skip to content
CryoCryo home
Stdlibfuture

ready

import std::future::ready; · source

Ready<T>

type struct Ready<T> {
    value: Option<T>;

    static new(value: T) -> Ready<T>;
}

Ready::new(value) is a future that completes immediately — useful for testing and for satisfying a Future bound with a value you already have.

PendingThenReady<T>

type struct PendingThenReady<T> {
    remaining: u32;
    value:     Option<T>;

    static new(pending_count: u32, value: T) -> PendingThenReady<T>;
}

PendingThenReady::new(n, value) returns Pending for the first n polls, waking itself each time, then completes — the simplest way to exercise an executor's re-scheduling path in a test.

Both panic if polled again after completing.

Trait implementations

implement<T> trait Future<T> for struct Ready<T>

implement<T> trait Future<T> for struct PendingThenReady<T>