Macro expecting::expect_none
source · macro_rules! expect_none { ( $option:expr ) => { ... }; }
Expand description
Expects that the given Option
is None
; otherwise returns early.
§Examples
fn passing_test() -> Result<()> {
expect_none!(None::<()>);
Ok(())
}
fn failing_test() -> Result<()>{
expect_none!(Some(())); // returns early
Ok(()) // won't be reached
}
failing_test()
will return early after calling expect_none!
. The Err
will be wrapped in a
descriptive error message such as:
[my/file.rs:12] “expect_none!(option)” Expected None, got Some: [ contents ]“
[ … wrapped Err details …]