pub fn reject_with<T: PartialEq>(
it: impl Iterator<Item = T>,
callback: impl FnMut(&T) -> bool,
) -> Result<impl Iterator<Item = T>, Infallible>Expand description
Returns an iterator without filtered out values.
fn is_odd(v: &&u32) -> bool {
**v & 1 != 0
}
#[derive(Template)]
#[template(
ext = "html",
source = r#"{% for elem in numbers | reject(self::is_odd) %}{{ elem }},{% endfor %}"#,
)]
struct Example {
numbers: Vec<u32>,
}
assert_eq!(
Example { numbers: vec![1, 2, 3, 4] }.to_string(),
"2,4,"
);