Trait assertor::ResultAssertion
source · pub trait ResultAssertion<R, OK, ERR> {
// Required methods
fn is_ok(&self) -> R;
fn is_err(&self) -> R;
fn has_ok<B: Borrow<OK>>(&self, expected: B) -> R
where OK: PartialEq;
fn has_err<B: Borrow<ERR>>(&self, expected: B) -> R
where ERR: PartialEq;
fn ok(&self) -> Subject<'_, OK, (), R>;
fn err(&self) -> Subject<'_, ERR, (), R>;
}
Expand description
Trait for result assertion.
§Example
use assertor::*;
let ok : Result<usize, usize>= Ok(0);
let err : Result<usize, usize>= Err(1);
assert_that!(ok).is_ok();
assert_that!(err).is_err();
assert_that!(ok).has_ok(0);
assert_that!(err).has_err(1);
Required Methods§
sourcefn is_ok(&self) -> R
fn is_ok(&self) -> R
Checks that the subject is Result::Ok(_)
.
sourcefn is_err(&self) -> R
fn is_err(&self) -> R
Checks that the subject is Result::Err(_)
.
sourcefn has_ok<B: Borrow<OK>>(&self, expected: B) -> Rwhere
OK: PartialEq,
fn has_ok<B: Borrow<OK>>(&self, expected: B) -> Rwhere
OK: PartialEq,
Checks that the subject is Result::Ok(expected)
.
sourcefn has_err<B: Borrow<ERR>>(&self, expected: B) -> Rwhere
ERR: PartialEq,
fn has_err<B: Borrow<ERR>>(&self, expected: B) -> Rwhere
ERR: PartialEq,
Checks that the subject is Result::Err(expected)
.
Object Safety§
This trait is not object safe.