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

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

Structs

Enums