std-method

Poll::is_ready and is_pending

Inspect the state without extracting the completed value. In a real poll loop, receiving Pending normally returns control to the scheduler; checking it repeatedly cannot make a blocked resource ready. Expected stdout (not executed): true true Common mistake: Implementing an unbounded busy loop around is_pending.

Formal Syntax & Structure

rust syntaxrust
p.is_ready() -> bool; p.is_pending() -> bool

Working Example

Example Snippetrust
fn main() {    use std::task::Poll;    let ready = Poll::Ready("done");    let waiting = Poll::<&str>::Pending;    println!("{} {}", ready.is_ready(), waiting.is_pending());}
Rust Reference