Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow non-vec filters #422

Closed
konstin opened this issue Nov 1, 2023 · 2 comments
Closed

Allow non-vec filters #422

konstin opened this issue Nov 1, 2023 · 2 comments

Comments

@konstin
Copy link

konstin commented Nov 1, 2023

Filters such as

    insta::with_settings!({
        filters => vec![
            (r"\d+(ms|s)", "[TIME]"),
        ]
    }, {
        assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
            .arg("compile")
            .arg("input.txt")
    });

currently require a Vec:

insta/src/filters.rs

Lines 12 to 20 in 324cd71

impl<'a> From<Vec<(&'a str, &'a str)>> for Filters {
fn from(value: Vec<(&'a str, &'a str)>) -> Filters {
let mut rv = Filters::default();
for (regex, replacement) in value {
rv.add(regex, replacement);
}
rv
}
}

Could this requirement be lifted to allow slices or any iterable? I'd like to use e.g.

    insta::with_settings!({
        filters => INSTA_FILTERS
    }, {
        assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
            .arg("compile")
            .arg("input.txt")
    });
@mitsuhiko
Copy link
Owner

There is a PR open for it, but I haven't had the courage yet to make the change. #400

@max-sixty
Copy link
Collaborator

Closed by 1d70238

@konstin konstin closed this as completed Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants