galvanic_assert::matchers::collection

Function has_value

Source
pub fn has_value<'a, K: 'a, V: 'a, M: 'a>(
    key: K,
) -> Box<dyn Matcher<'a, M> + 'a>
where &'a M: IntoIterator<Item = (&'a K, &'a V)> + 'a, HasKey<K>: Matcher<'a, M>,
Expand description

Matches if the map-like collection contains the given value.

The Matcher tests for this by converting the map-like data structure into a key/value pair iterator.

#Examples

use galvanic_assert::matchers::collection::*;
let mut map = std::collections::HashMap::<i32,i32>::new();
map.insert(0, 2);
map.insert(1, 2);
map.insert(2, 5);
map.insert(3, 3);
map.insert(4, 3);

assert_that!(&map, has_value(3));