pub fn try_set<I, E>(
predicate: fn(&I) -> Result<bool, E>,
) -> impl Fn(&HashSet<I>) -> Result<bool, E>Expand description
Checks if all elements in the HashSet satisfy the predicate (fallible ones accepted).
#[derive(Debug, Valust)]
struct All {
#[valid(func(try(try_set(|x: &String| x.parse::<i32>().map(|u| u > 1)))))]
data: HashSet<String>
}
let all = Raw::<All> { data: vec!["1".to_owned(), "2".to_owned(), "3".to_owned()].into_iter().collect() };
let val = All::validate(all);
assert!(val.is_err());
println!("{}", val.unwrap_err().full_stringify());