Struct ContainsMatcher

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

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

Implementations§

Source§

impl<InnerMatcherT> ContainsMatcher<InnerMatcherT>

Source

pub fn times(self, count: impl Matcher<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 + Copy, InnerMatcherT: Matcher<T>, ContainerT> Matcher<ContainerT> for ContainsMatcher<InnerMatcherT>
where ContainerT: IntoIterator<Item = T> + Debug + Copy,

Source§

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

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

fn explain_match(&self, actual: ContainerT) -> 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§

impl<InnerMatcherT> MatcherBase for ContainsMatcher<InnerMatcherT>

Source§

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

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

fn or<Right>(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<InnerMatcherT> Freeze for ContainsMatcher<InnerMatcherT>
where InnerMatcherT: Freeze,

§

impl<InnerMatcherT> !RefUnwindSafe for ContainsMatcher<InnerMatcherT>

§

impl<InnerMatcherT> !Send for ContainsMatcher<InnerMatcherT>

§

impl<InnerMatcherT> !Sync for ContainsMatcher<InnerMatcherT>

§

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

§

impl<InnerMatcherT> !UnwindSafe for ContainsMatcher<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>,

Source§

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>,

Source§

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.