zeta12ti / parse_duration

Parses a duration from a string.
MIT License
17 stars 2 forks source link

Error privacy #16

Closed zeta12ti closed 4 years ago

zeta12ti commented 4 years ago

Make the parse module public, allowing parse::Error to be matched on.

For example, now

use parse_duration::parse;

let input = "1e100 seconds";

if let Err(parse::Error::OutOfBounds(_)) = parse(input) {
    println!("The input was too big");
} else {
    panic!("The input wasn't too big");
}

will work.