Trait SetAssertion

Source
pub trait SetAssertion<'a, S, T, R> {
    // Required methods
    fn has_length(&self, length: usize) -> R;
    fn is_empty(&self) -> R
       where T: Debug;
    fn contains<B: Borrow<T>>(&self, expected: B) -> R
       where T: PartialEq + Eq + Debug + Hash;
    fn does_not_contain<B>(&self, element: B) -> R
       where B: Borrow<T>,
             T: PartialEq + Debug;
    fn does_not_contain_any<B: Borrow<Vec<T>>>(&self, elements: B) -> R
       where T: PartialEq + Debug;
}
Expand description

Trait for set assertion.

§Example

use assertor::*;
use std::collections::HashSet;

let mut set = HashSet::new();
assert_that!(set).is_empty();

set.insert("a");
set.insert("b");
set.insert("c");

assert_that!(set).contains("a");
assert_that!(set).has_length(3);
use assertor::*;
use std::collections::HashSet;

let mut set = HashSet::new();
set.insert("a");
assert_that!(set).contains("z");
// expected to contain  : "z"
// but did not
// though it did contain: ["a"]

Required Methods§

Source

fn has_length(&self, length: usize) -> R

Checks that the subject has the given length.

Source

fn is_empty(&self) -> R
where T: Debug,

Checks that the subject is empty.

Source

fn contains<B: Borrow<T>>(&self, expected: B) -> R
where T: PartialEq + Eq + Debug + Hash,

Checks that the subject has expected.

Source

fn does_not_contain<B>(&self, element: B) -> R
where B: Borrow<T>, T: PartialEq + Debug,

Checks that the subject does not contain element.

Source

fn does_not_contain_any<B: Borrow<Vec<T>>>(&self, elements: B) -> R
where T: PartialEq + Debug,

Checks that the subject does not contain any element of elements.

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<'a, T, R, ST> SetAssertion<'a, ST, T, R> for Subject<'a, ST, (), R>
where AssertionResult: AssertionStrategy<R>, T: Eq + Debug, ST: SetLike<T>,