Closed intarga closed 2 months ago
@olliemath I think this is good to go. A couple of notes though:
Date
are intentional and probably just need an annotation to suppress the warning, as for the uses of from_ymd()
it seems like we should switch to from_ymd_opt()
.Thanks so much for this.
For 1, yes this currently requires suppressing the warning, however I'm planning to remove support for the deprecated chrono types and functions in 0.3 (can't do this in a minor release).
For 2, property based testing is nice in small amounts, and I'm not adverse to adding another dev dependency. Apart from checking that the parse and format functions don't throw weird errors with arbitrary inputs, we would ideally have a test along the lines of:
assert_eq!(d, RelativeDuration::from_iso_8601(d.to_iso_8601()))
That's the easy direction because equality between RelativeDurations is stable under transformations like Y1M1 -> M13
. The harder direction is a check along the lines of
assert_eq!(s, RelativeDuration::from_iso_8601(s).to_iso_8601())
because this will only hold for strings in "reduced" form, so you need a smart generation strategy to generate examples in this form.
Would it be possible to add some benchmarks for cargo bench (see the benches directory for an example). This way we can work on optimisations in the future.
Thanks for the thorough review! I added property tests and benchmarks as requested.
Thanks for adding the tests and benchmarks - this looks good - will merge and prepare for the 0.2.7 release.
I plan make one small tweak to rename of the functions from iso_8601
to iso8601
for greater harmony with chrono's parse function names (e.g. parse_from_rfc3339
)
Resolves #13