pub fn has_key<'a, K: 'a, V: 'a, M: 'a>(key: K) -> Box<dyn Matcher<'a, M> + 'a>
Expand description
Matches if the map-like collection contains the given key.
The Matcher
tests for this by converting the map-like data structure
into a key/value pair iterator.
The alternative would be to use the Index trait though experiments showed
that this would not be composable with all_of!
or any_of!
.
#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_key(2));