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§

source

fn is_ok(&self) -> R

Checks that the subject is Result::Ok(_).

source

fn is_err(&self) -> R

Checks that the subject is Result::Err(_).

source

fn has_ok<B: Borrow<OK>>(&self, expected: B) -> R
where OK: PartialEq,

Checks that the subject is Result::Ok(expected).

source

fn has_err<B: Borrow<ERR>>(&self, expected: B) -> R
where ERR: PartialEq,

Checks that the subject is Result::Err(expected).

source

fn ok(&self) -> Subject<'_, OK, (), R>

Returns a new subject which is the ok value of the subject if the subject has ok value. Otherwise, it fails.

source

fn err(&self) -> Subject<'_, ERR, (), R>

Returns a new subject which is the error value of the subject if the subject has error value. Otherwise, it fails.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<R, OK: Debug, ERR: Debug> ResultAssertion<R, OK, ERR> for Subject<'_, Result<OK, ERR>, (), R>