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§
Sourcefn ok(self) -> Spec<'a, &'a T, R>
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]);
Sourcefn err(self) -> Spec<'a, &'a E, R>
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");