AssertOptionValue

Trait AssertOptionValue 

Source
pub trait AssertOptionValue<'a, T, R> {
    // Required method
    fn some(self) -> Spec<'a, T, R>;
}
Expand description

Assert the value of an option by mapping the subject.

If the option is none, the assertion fails.

§Examples

use asserting::prelude::*;

let subject: Option<Vec<usize>> = Some(vec![1, 2, 3]);
assert_that!(subject).some().contains_exactly([1, 2, 3]);

let subject: Option<&str> = Some("ullamco cupiditat diam hendrerit");
assert_that!(subject).some().is_not_empty();

Required Methods§

Source

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

Maps the subject to the option’s value if it has some. Otherwise, this assertion fails.

§Examples
use asserting::prelude::*;

let subject: Option<Vec<usize>> = Some(vec![1, 2, 3]);
assert_that!(subject).some().contains_exactly([1, 2, 3]);

let subject: Option<&str> = Some("ullamco cupiditat diam hendrerit");
assert_that!(subject).some().is_not_empty();

Implementors§

Source§

impl<'a, T, R> AssertOptionValue<'a, T, R> for Spec<'a, Option<T>, R>
where R: FailingStrategy,