Skip to main content

Crate numeric_range

Crate numeric_range 

Source
Expand description

§numeric-range — compact integer-range strings

Parse and format the familiar "1,3-5,7" range syntax used by print dialogs (page ranges), CPU affinity lists (taskset/cgroups), line selectors, and CLI flags — in both directions.

assert_eq!(numeric_range::parse("1,3-5,7").unwrap(), vec![1, 3, 4, 5, 7]);
assert_eq!(numeric_range::format(&[1, 3, 4, 5, 7]), "1,3-5,7");

Zero dependencies, #![no_std] (needs only alloc).

Enums§

ParseError
An error produced by parse.

Functions§

format
Format a slice of integers into a compact range string, e.g. [1, 3, 4, 5, 7]"1,3-5,7". Values are sorted and de-duplicated first.
parse
Parse a compact range string like "1,3-5,7" into the expanded values, preserving input order.