Trait AssertBorrowedResultValue

Source
pub trait AssertBorrowedResultValue<'a, T, E, R> {
    // Required methods
    fn ok(self) -> Spec<'a, &'a T, R>;
    fn err(self) -> Spec<'a, &'a E, R>;
}
Expand description

Assert the ok-value or error of a borrowed result by mapping the subject.

§Examples

use asserting::prelude::*;

let subject: Result<Vec<usize>, String> = Ok(vec![1, 2, 3]);
assert_that!(&subject).ok().is_not_empty();

let subject: Result<u64, String> = Err("te anim adipisici mollit".to_string());
assert_that!(&subject).err().is_equal_to("te anim adipisici mollit");

Required Methods§

Source

fn ok(self) -> Spec<'a, &'a T, R>

Maps the subject to the result’s ok value.

If the result is an error, this method panics.

§Examples
use asserting::prelude::*;

let subject: Result<Vec<usize>, String> = Ok(vec![1, 2, 3]);
assert_that!(&subject).ok().contains_exactly(&[1, 2, 3]);
Source

fn err(self) -> Spec<'a, &'a E, R>

Maps the subject to the result’s err value.

If the result is an ok value, this method panics.

§Examples
use asserting::prelude::*;

let subject: Result<u64, String> = Err("te anim adipisici mollit".to_string());
assert_that!(&subject).err().is_equal_to("te anim adipisici mollit");

Implementors§

Source§

impl<'a, T, E, R> AssertBorrowedResultValue<'a, T, E, R> for Spec<'a, &'a Result<T, E>, R>
where T: Debug, E: Debug,