Macro claim::assert_ready_ok
source · [−]macro_rules! assert_ready_ok {
($cond:expr,) => { ... };
($cond:expr) => { ... };
($cond:expr, $($arg:tt)+) => { ... };
}
Expand description
Asserts that expression returns Poll::Ready(Ok(T))
variant.
This macro is available for Rust 1.36+.
Uses
Assertions are always checked in both debug and release builds, and cannot be disabled.
See debug_assert_ready_ok!
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<Result<i32, ()>> = Poll::Ready(Ok(42));
assert_ready_ok!(res);
Value of T
type from the Poll::Ready(Ok(T))
will also be returned from this macro call:
let res: Poll<Result<i32, ()>> = Poll::Ready(Ok(42));
let value = assert_ready_ok!(res);
assert_eq!(value, 42);
Both Poll::Ready(Err(..))
and Poll::Pending
variants will cause panic:
ⓘ
let res: Poll<Result<i32, ()>> = Poll::Ready(Err(()));
assert_ready_ok!(res); // Will panic
ⓘ
let res: Poll<Result<i32, ()>> = Poll::Pending;
assert_ready_ok!(res); // Will panic