diff --git a/CHANGELOG.md b/CHANGELOG.md index 402d64d2..cd017218 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,8 @@ All notable changes to insta and cargo-insta are documented here. - Add a new integration test approach for `cargo-insta` and a set of integration tests. #537 +- Enable Filters to be created from `IntoIterator` types, rather than just `Vec`s. #570 + ## 1.39.0 - Fixed a bug in `require_full_match`. #485 diff --git a/insta/src/filters.rs b/insta/src/filters.rs index be0485ee..5c64d1ad 100644 --- a/insta/src/filters.rs +++ b/insta/src/filters.rs @@ -1,5 +1,6 @@ use std::borrow::Cow; use std::iter::FromIterator; +use std::iter::IntoIterator; use regex::Regex; @@ -10,9 +11,12 @@ pub struct Filters { rules: Vec<(Regex, String)>, } -impl<'a> From<Vec<(&'a str, &'a str)>> for Filters { - fn from(value: Vec<(&'a str, &'a str)>) -> Self { - Self::from_iter(value) +impl<'a, I> From<I> for Filters +where + I: IntoIterator<Item = (&'a str, &'a str)>, +{ + fn from(value: I) -> Self { + Self::from_iter(value.into_iter()) } }