parse_csl 0.1.0

parse comma seperated lists into generic type which implements FromStr
Documentation
1
2
3
4
5
6
7
8
9
10
11
use std::str::FromStr;

pub fn parse_comma_seperated<T: FromStr>(csl: &str) -> Result<Vec<T>, T::Err> {
    csl.split(",")
        .filter(|item| item.len() > 0)
        .map(|item| {
            let item = item.parse()?;
            Ok::<T, T::Err>(item)
        })
        .collect()
}