Skip to main content

parse

Function parse 

Source
pub fn parse(input: &str) -> Vec<i64>
Expand description

Parse input into the list of integers it describes.

The input is split on commas; each entry is either a number ("42", "-3") or a range ("1-5", "1...5"). Unrecognized entries are skipped. Duplicates are kept (no deduplication), matching the reference implementation.

assert_eq!(parse("1-3,7,9-11"), [1, 2, 3, 7, 9, 10, 11]);
assert_eq!(parse(",,1,,2,,"), [1, 2]);
assert_eq!(parse("nope"), [] as [i64; 0]);