pub trait OptionAssertion<T, R>where
AssertionResult: AssertionStrategy<R>,{
// Required methods
fn is_none(&self) -> R
where T: PartialEq + Debug;
fn is_some(&self) -> R
where T: PartialEq + Debug;
fn has_value<B>(&self, expected: B) -> R
where B: Borrow<T>,
T: PartialEq + Debug;
fn some(&self) -> Subject<'_, T, (), R>
where T: PartialEq + Debug;
}Expand description
Trait for option assertion.
§Example
use assertor::*;
assert_that!(Option::Some(1)).has_value(1);
assert_that!(Option::Some(1)).is_some();
assert_that!(Option::<usize>::None).is_none();
assert_that!(Option::Some("foobar")).some().starts_with("foo");Required Methods§
Sourcefn is_none(&self) -> R
fn is_none(&self) -> R
Checks the subject is Option::None.
Sourcefn is_some(&self) -> R
fn is_some(&self) -> R
Checks the subject is Option::Some(_).
Sourcefn has_value<B>(&self, expected: B) -> R
fn has_value<B>(&self, expected: B) -> R
Checks the subject is Option::Some(expected).
Sourcefn some(&self) -> Subject<'_, T, (), R>
fn some(&self) -> Subject<'_, T, (), R>
Returns a new subject which is the value of the subject if the subject is Option::Some(_). Otherwise, it fails.
§Example
use assertor::*;
let value = Option::Some("foobar");
assert_that!(value).some().starts_with("foo");
assert_that!(value).some().ends_with("bar");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.