zslayton / cron

A cron expression parser in Rust
Apache License 2.0
376 stars 69 forks source link

Impl TryFrom<&str> for Schedule #98

Closed hgzimmerman closed 2 years ago

hgzimmerman commented 2 years ago

A downstream crate I use exposes an API that takes strings, converts them to Schedules, which may fail. Ideally, I'd like to construct Schedules myself and pass them to the crate's functions, and handle possible errors before the library has a chance to produce errors. For this to be practical, it would need to avoid breaking API compatibility so severely, and the best way to do that would be for their functions to take the schedule argument as a S: TryInto<cron::Schedule>.

If TryFrom<&str> for Schedule is implemented, this will allow the functions to take &strs like they do currently, as well as support taking cron::Schedule, since it has a blanket impl for TryFrom<T> for T.