std-function
future::pending: a deliberately unfinished future
Construct a future that never yields a value. It is useful for disabling a branch or demonstrating unfinished state; awaiting it unconditionally will not finish. The fixture samples it once and drops it, using no blocking loop. Expected stdout (not executed): true Common mistake: Waiting unconditionally for a pending future to produce a value.
Formal Syntax & Structure
rust syntaxrust
std::future::pending::<T>() -> Pending<T>Working Example
Example Snippetrust
fn main() { use std::{future::Future, task::{Context, Poll, Wake, Waker}, sync::Arc}; struct Noop; impl Wake for Noop { fn wake(self: Arc<Self>) {} } let w = Waker::from(Arc::new(Noop)); let mut cx = Context::from_waker(&w); let mut f = std::pin::pin!(std::future::pending::<u32>()); println!("{}", f.as_mut().poll(&mut cx).is_pending());}