Skip to main content

IterableCountExpectations

Trait IterableCountExpectations 

Source
pub trait IterableCountExpectations<'e, B>
where B: ExpectationBuilder<'e>,
{ // Required methods fn count(self) -> impl ExpectationBuilder<'e, Value = usize> where Self: Sized; fn to_not_be_empty(self) -> Self; fn to_be_empty(self) -> Self; }
Expand description

Extension trait for equality expectations for iterables

Required Methods§

Source

fn count(self) -> impl ExpectationBuilder<'e, Value = usize>
where Self: Sized,

Make expectations on the number of items in the iterable.

Don’t call this on never-ending iterables.


let items = vec!["bar", "foo", "foo"];
expect(items).count().to_be_greater_than_or_equal(2);

asserts that items contains at least 2 items

Source

fn to_not_be_empty(self) -> Self

Expect an iterable to not be empty.


let items = vec!["bar", "foo", "foo"];
expect(items).to_not_be_empty();

asserts that items contains at least one item

Source

fn to_be_empty(self) -> Self

Expect an iterable to be empty.


let items: Vec<u8> = vec![];
expect(items).to_be_empty();

asserts that items contains no items

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<'e, I, C, B> IterableCountExpectations<'e, B> for B
where I: Debug + 'e, for<'a> &'a I: IntoIterator<Item = &'a C>, C: Debug, B: ExpectationBuilder<'e, Value = I>,