#parse #range

prange2

Parse numeric ranges for indexing

2 stable releases

✓ Uses Rust 2018 edition

2.0.1 May 13, 2019

#7 in #range

3 downloads per month

GPL-3.0+

16KB
222 lines

prange

Parse numeric ranges for indexing.

Inclusive-inclusive 1-based integer ranges. Parsed from strings.

Examples

"2"         => [2]
"1-5"       => [1, 2, 3, 4, 5]
"1-3,5-6"   => [1, 2, 3, 5, 6]
"-3"        => [1, 2, 3]
"1-"        => [1, 2, 3, ..]
"1-3,2-4,7" => [1, 2, 3, 2, 3, 4, 7]

lib.rs:

Parse numeric ranges for indexing.

Inclusive-inclusive 1-based integer ranges. Parsed from strings.

Examples

"2"         => [2]
"1-5"       => [1, 2, 3, 4, 5]
"1-3,5-6"   => [1, 2, 3, 5, 6]
"-3"        => [1, 2, 3]
"1-"        => [1, 2, 3, ..]
"1-3,2-4,7" => [1, 2, 3, 2, 3, 4, 7]

No runtime deps