diff --git a/src/input.rs b/src/input.rs index a886a41..fbe8316 100644 --- a/src/input.rs +++ b/src/input.rs @@ -63,3 +63,15 @@ where .map(str::to_string) .collect() } + +/// Parses a string of whitespace separated elements and returns them as +/// a collection. +pub fn parse_ws_separated(s: &str) -> B +where + B: FromIterator, + ::Err: Debug, +{ + s.split_ascii_whitespace() + .map(|n| n.parse().unwrap()) + .collect() +}