4 stable releases

new 3.0.1 Nov 20, 2024
3.0.0 Aug 28, 2024
2.0.1 May 13, 2019

#437 in Rust patterns

Download history 3/week @ 2024-07-24 1/week @ 2024-07-31 140/week @ 2024-08-28 13/week @ 2024-09-11 13/week @ 2024-09-18 8/week @ 2024-09-25 4/week @ 2024-10-02

266 downloads per month

MIT/Apache

9KB
219 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]

Dependencies

~0.4–0.9MB
~19K SLoC