Trait 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.

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.

Implementors§

Source§

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