Function range_parser::parse
source · pub fn parse<T>(range_str: &str) -> RangeResult<Vec<T>>
Expand description
Parse a range string to a vector of usize
§Arguments
- range_str: &str - the range string to parse
§Returns
- Result<Vec
, RangeError> - the parsed range
§Example
let range: Vec<u64> = range_parser::parse::<u64>("0-3").unwrap();
assert_eq!(range, vec![0, 1, 2, 3]);
let range: Vec<u64> = range_parser::parse::<u64>("0,1,2,3").unwrap();
assert_eq!(range, vec![0, 1, 2, 3]);
let range: Vec<i32> = range_parser::parse::<i32>("0,3,5-8,-1").unwrap();
assert_eq!(range, vec![0, 3, 5, 6, 7, 8, -1]);