1
0
Fork 0

feat(input): add ‹parse_separated›

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2023-12-12 11:37:15 +01:00
parent 9abfb4d18d
commit 501d8cb515
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -75,3 +75,13 @@ where
.map(|n| n.parse().unwrap())
.collect()
}
/// Parses a string of separated elements with given character and returns them
/// as a collection.
pub fn parse_separated<B, T: FromStr>(c: char, s: &str) -> B
where
B: FromIterator<T>,
<T as FromStr>::Err: Debug,
{
s.split(c).map(|n| n.parse().unwrap()).collect()
}