Description
Hi,
You asked for some suggestions on how to improve hifitime
; I've found a couple!
The Rust API Guidelines provide some "rules" on how to name methods, whether into_
, to_
or as_
. Just now as I was poking some code, I realised that hifitime::Duration
doesn't really follow this, and I think it would make the API better or at least more consistent with existing Rust APIs (e.g. Duration::in_seconds
should be Duration::to_seconds
). Another bugbear of mine is Duration::from_f64
; this method could remain, but I think it would be nicer to use Duration::from_secs
, Duration::from_millis
etc., which is very similar to the standard library functions.
hifitime::Epoch
technically is correct with its many as_
methods, although these methods borrow self
when Epoch
is already Copy
(i.e. these methods don't need to borrow, and given the guidelines these methods should instead be named to_
).
The #[deprecated = reason]
annotation can be used to maintain semver compatibility while introducing any new methods.
What do you think? It would be a decent amount of work to vet all existing methods, but I think it would be worth it. There is no rush on this work as it's mostly a matter of taste, and I would be happy to pitch in but I'm likely too busy until early next year.
Once again, thanks for your help with this great library.