use std::str::{pattern::Pattern, FromStr}; pub fn to_vec(s: &str, pat: P) -> Vec where T: FromStr, P: Pattern, { s.split(pat).filter_map(|x| x.parse().ok()).collect() } pub fn to_vec_map(s: &str, pat: P, func: impl FnMut(T) -> U) -> Vec where T: FromStr, P: Pattern, { s.split(pat) .filter_map(|x| x.parse().ok()) .map(func) .collect() }