diff --git a/exercises/matching-brackets/example.rs b/exercises/matching-brackets/example.rs index 44310d294..8d3e46858 100644 --- a/exercises/matching-brackets/example.rs +++ b/exercises/matching-brackets/example.rs @@ -57,12 +57,9 @@ impl From> for MatchingBrackets { impl MatchingBrackets { fn contains(&self, other: &char) -> bool { - let known = self - .collection - .keys() - .chain(self.collection.values()) - .collect::>(); - known.contains(&other) + self.collection + .iter() + .any(|(k, v)| k == other || v == other) } fn closer_for(&self, k: &char) -> Option<&char> {