Crate number_range

Source
Expand description

§Introduction

To convert from human readable number range into an iterator. It makes it easy to parse the command line arguments in the form of num, num1:num2, num1:step:num2 or comma separated list of them.

§Features

  • Parse from human redable format into an iterator (NumberRange<T>) for any generic number format
  • Configuration options for list and range separators (NumberRangeOptions). You can also use it to provide options to parse numbers in different localization, like grouping or different decimal separator.

§Limitations

  • Step size needs to be the same type as the number type, which means you can’t use negative numbers for unsigned numbers.
  • Automatic step size can only be one, not negative one as the code is generic for unsigned too, so if you want negative step for signed numbers you need to specify that.
  • Although it works with floats as well, not just integers, the float step size might not be accurate.

Macros§

numrng
Macro rule for generating number range. The NumberRange<T> is made with default options, then parsed.
numvec
Macro rule for generating number range into vec. The NumberRange<T> is made with default options, then parsed and collected into a Vec.

Structs§

NumberRange
Representation of Number Ranges, once you’ve parsed the string you can iterate though it.
NumberRangeError
NumberRangeOptions
Options for the NumberRange, includes different separator character customization.

Enums§

Number
Number type for simple interger numbers or number range. The NumberRange<T> is made up of these, so you can use it to build the NumberRange<T> manually.