4 stable releases

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

#456 in Rust patterns

Download history 118/week @ 2024-08-23 22/week @ 2024-08-30 17/week @ 2024-09-13 15/week @ 2024-09-20 4/week @ 2024-09-27 2/week @ 2024-10-04 116/week @ 2024-11-15 33/week @ 2024-11-22 5/week @ 2024-11-29

154 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.3–0.8MB
~19K SLoC