2022-11-29 21:06:00 +01:00
|
|
|
use std::{fmt::Debug, str::FromStr};
|
2022-11-28 22:42:47 +01:00
|
|
|
|
2022-11-29 21:06:00 +01:00
|
|
|
pub fn to_vec<T>(input: &str, split: char) -> Vec<T>
|
|
|
|
where
|
|
|
|
T: FromStr,
|
|
|
|
<T as FromStr>::Err: Debug,
|
|
|
|
{
|
|
|
|
input
|
|
|
|
.split(split)
|
|
|
|
.map(|x| x.parse::<T>().unwrap())
|
|
|
|
.collect()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn to_vec_vec<T>(input: &str, split_rows: char, split_row: char) -> Vec<Vec<T>>
|
|
|
|
where
|
|
|
|
T: FromStr,
|
|
|
|
<T as FromStr>::Err: Debug,
|
|
|
|
{
|
|
|
|
input
|
|
|
|
.split(split_rows)
|
|
|
|
.map(|x| {
|
|
|
|
x.split(split_row)
|
|
|
|
.map(|y| y.parse::<T>().unwrap())
|
|
|
|
.collect()
|
|
|
|
})
|
|
|
|
.collect()
|
|
|
|
}
|