From 501d8cb515c695847b1a751c59caa4a39fb4b897 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Tue, 12 Dec 2023 11:37:15 +0100 Subject: [PATCH] =?UTF-8?q?feat(input):=20add=20=E2=80=B9parse=5Fseparated?= =?UTF-8?q?=E2=80=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Matej Focko --- src/input.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/input.rs b/src/input.rs index fbe8316..c4ba76e 100644 --- a/src/input.rs +++ b/src/input.rs @@ -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(c: char, s: &str) -> B +where + B: FromIterator, + ::Err: Debug, +{ + s.split(c).map(|n| n.parse().unwrap()).collect() +}