Skip to main content

contains

Function contains 

Source
pub fn contains<InnerMatcherT>(
    inner: InnerMatcherT,
) -> ContainsMatcher<InnerMatcherT>
Expand description

Matches an IntoIterator type whose elements contain a value matched by inner.

By default, this matches a container with any number of elements matched by inner. Use the method ContainsMatcher::times to constrain the matched containers to a specific number of matching elements.

verify_that!(["Some value"], contains(eq("Some value")))?;  // Passes
verify_that!(vec!["Some value"], contains(eq(&"Some value")))?;  // Passes
verify_that!([] as [&String; 0], contains(eq("Some value")))?;   // Fails
verify_that!(["Some value"], contains(eq("Some other value")))?;   // Fails