claims

Macro assert_pending

Source
macro_rules! assert_pending {
    ($cond:expr $(,)?) => { ... };
    ($cond:expr, $($arg:tt)+) => { ... };
}
Expand description

Asserts that the expression matches a Poll::Pending variant.

§Uses

Assertions are always checked in both debug and release builds, and cannot be disabled. See debug_assert_pending! for assertions that are not enabled in release builds by default.

§Custom messages

This macro has a second form, where a custom panic message can be provided with or without arguments for formatting. See std::fmt for syntax for this form.

§Examples

let res: Poll<i32> = Poll::Pending;

assert_pending!(res);

// With a custom message
assert_pending!(res, "Future is not ready yet");

A Poll::Pending variant will also be returned from this macro call:

let res: Poll<i32> = Poll::Pending;

let value = assert_pending!(res);
assert_eq!(value, Poll::Pending);

A Poll::Ready(_) variant will panic:

let res = Poll::Ready(42);

assert_pending!(res);  // Will panic