Skip to main content

parse_range

Function parse_range 

Source
pub fn parse_range<T>(
    s: &str,
    limits: RangeInclusive<T>,
) -> Result<RangeInclusive<T>>
where T: FromStr + Copy + PartialOrd + Display, <T as FromStr>::Err: Error + Sync + Send + 'static,
Expand description

Parse a range from an input string, using values in limits as defaults.

Start and end values must be a type that is parseable from a string. Ranges are inclusive. Whitespace is trimmed from start and end values before parsing.

Valid ranges:

  • Range of values (e.g. 1990..2000)
  • Range with no upper limit (e.g. 1990..)
  • Range with no lower limit (e.g. ..2000)