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