use std::str::FromStr;
pub fn list_by_sep<const SEP: char, T, C>(input: &str) -> Result<C, <T as FromStr>::Err>
where
T: FromStr,
C: FromIterator<T>,
{
input.split(SEP).map(T::from_str).collect()
}
macro_rules! specify_fn_wrapper {
($fn_name:ident, $sep:literal) => {
#[doc = concat!("Like [`list_by_sep`] with `", $sep, "` separator.")]
pub fn $fn_name<T, C>(input: &str) -> Result<C, <T as FromStr>::Err>
where
T: FromStr,
C: FromIterator<T>,
{
list_by_sep::<$sep, _, _>(input)
}
}
}
specify_fn_wrapper!(list_by_comma, ',');
specify_fn_wrapper!(list_by_semicolon, ';');
specify_fn_wrapper!(list_by_colon, ':');
specify_fn_wrapper!(list_by_space, ' ');