Function parse_year_str

Source
pub fn parse_year_str(s: &str, valid_years: &[u32]) -> Result<Vec<u32>>
Expand description

Parse a string of years separated by semicolons into a vector of u32 years.

The string can be either “all” (case-insensitive), a single year, or a semicolon-separated list of years (e.g. “2020;2021;2022” or “2020; 2021; 2022”)

§Arguments

  • s - Input string to parse
  • valid_years - The possible years which can be referenced in s (must be sorted and unique)

§Returns

A Vec of years or an error.

§Panics

If valid_years is unsorted or non-unique.