pub struct ContainsMatcher<T, InnerMatcherT> { /* private fields */ }
Expand description

A matcher which matches a container containing one or more elements a given inner Matcher matches.

Implementations§

source§

impl<T, InnerMatcherT> ContainsMatcher<T, InnerMatcherT>

source

pub fn times(self, count: impl Matcher<ActualT = usize> + 'static) -> Self

Configures this instance to match containers which contain a number of matching items matched by count.

For example, to assert that exactly three matching items must be present, use:

contains(...).times(eq(3))

One can also use times(eq(0)) to test for the absence of an item matching the expected value.

Trait Implementations§

source§

impl<T: Debug, InnerMatcherT: Matcher<ActualT = T>, ContainerT: Debug> Matcher for ContainsMatcher<ContainerT, InnerMatcherT>
where for<'a> &'a ContainerT: IntoIterator<Item = &'a T>,

§

type ActualT = ContainerT

The type against which this matcher matches.
source§

fn matches(&self, actual: &Self::ActualT) -> MatcherResult

Returns whether the condition matches the datum actual. Read more
source§

fn explain_match(&self, actual: &Self::ActualT) -> Description

Prepares a String describing how the expected value encoded in this instance matches or does not match the given value actual. Read more
source§

fn describe(&self, matcher_result: MatcherResult) -> Description

Returns a description of self or a negative description if matcher_result is DoesNotMatch. Read more
source§

fn and<Right: Matcher<ActualT = Self::ActualT>>( self, right: Right ) -> ConjunctionMatcher<Self, Right>
where Self: Sized,

Constructs a matcher that matches both self and right. Read more
source§

fn or<Right: Matcher<ActualT = Self::ActualT>>( self, right: Right ) -> DisjunctionMatcher<Self, Right>
where Self: Sized,

Constructs a matcher that matches when at least one of self or right matches the input. Read more

Auto Trait Implementations§

§

impl<T, InnerMatcherT> !RefUnwindSafe for ContainsMatcher<T, InnerMatcherT>

§

impl<T, InnerMatcherT> !Send for ContainsMatcher<T, InnerMatcherT>

§

impl<T, InnerMatcherT> !Sync for ContainsMatcher<T, InnerMatcherT>

§

impl<T, InnerMatcherT> Unpin for ContainsMatcher<T, InnerMatcherT>
where InnerMatcherT: Unpin, T: Unpin,

§

impl<T, InnerMatcherT> !UnwindSafe for ContainsMatcher<T, InnerMatcherT>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.