time-rs / time

The most used Rust library for date and time handling.
https://time-rs.github.io
Apache License 2.0
1.13k stars 281 forks source link

Relation between `time::error::Error` and `time::error::Parse`? #558

Closed nc7s closed 1 year ago

nc7s commented 1 year ago

I tried to use time::error::Error as the source in my own error type, but rustc complains that result of Date::parse() is time::error::Parse. Is this distinction by design? Also, Error's doc says it's "A unified error type for anything returned by a method in the time crate". What's Parse's place here?

jhpratt commented 1 year ago

time::error::Parse is what is returned (and what should be used) when you are only parsing. time::error::Error can store any error type from time, such as if a component is out of range, obtaining the local offset failed, etc. Naturally, it can also store every variant of time::error::Parse.

In the future, please open a discussion rather than an issue for questions like this. It helps avoid clutter in the issue tracker.

nc7s commented 1 year ago

Ah, I'm not used to using discussions yet, sorry.