pub trait AssertNoneExt {
// Required methods
fn assert_none(self) -> Self;
fn debug_assert_none(self) -> Self;
}Expand description
An extension trait to add the assertion_none methods.
Required Methods§
Sourcefn assert_none(self) -> Self
fn assert_none(self) -> Self
Sourcefn debug_assert_none(self) -> Self
fn debug_assert_none(self) -> Self
Asserts the Option is None only in debug builds.
§Panics
The method panics if all following conditions are satisfied:
- It is
Some debug_assertionsis enabledpassthroughfeature is disabled
Otherwise, the method returns self as is.
§Examples
use chain_assertions::prelude::*;
let x: Option<i32> = None;
let x = x.debug_assert_none().map(|v| v * 2);
assert_eq!(x, None);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.