Trait assertor::OptionAssertion
source · 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");
Object Safety§
This trait is not object safe.