pub fn has_entry<KeyT, MatcherT>(
key: KeyT,
inner: MatcherT,
) -> HasEntryMatcher<KeyT, MatcherT>Expand description
Matches a &HashMap containing the given key whose value is matched by
the matcher inner.
let value = HashMap::from([(0, 1), (1, -1)]);
verify_that!(value, has_entry(0, eq(&1)))?; // Passes
verify_that!(value, has_entry(1, gt(&0)))?; // Fails: value not matched
verify_that!(value, has_entry(2, eq(&0)))?; // Fails: key not presentNote: One could obtain the same effect by using contains and a
Matcher<(&Key, &Value)>:
let value = HashMap::from([(0, 1), (1, -1)]);
verify_that!(value, contains(eq((&0, &1))))?;