Rename Duration to TimeDelta, add type alias - #1406
Conversation
a1a070a to
dc814ab
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1406 +/- ##
=======================================
Coverage 91.84% 91.85%
=======================================
Files 38 38
Lines 17518 17526 +8
=======================================
+ Hits 16090 16098 +8
Misses 1428 1428 ☔ View full report in Codecov by Sentry. |
4c84e2d to
174f04a
Compare
pitdicker
left a comment
There was a problem hiding this comment.
Did a review of all lines. It was not a trivial find-and-replace, but it seems like I didn't mangle things.
|
You refer to |
|
|
There was a little discussion on possible names in #1137 (comment). I don't care deeply about the names, but |
djc
left a comment
There was a problem hiding this comment.
Okay -- do we want to deprecate the Duration alias, and if so, when?
|
|
||
| mod duration; | ||
| pub use duration::Duration; | ||
| /// Alias of [`Duration`] |
There was a problem hiding this comment.
This should be formatted as a type, that is, with empty lines around it and not between a bunch of imports.
| //! [`Duration::from_std`](https://docs.rs/time/0.1.40/time/struct.Duration.html#method.from_std) | ||
| //! and | ||
| //! [`Duration::to_std`](https://docs.rs/time/0.1.40/time/struct.Duration.html#method.to_std) | ||
| //! ### Time span / Duration |
There was a problem hiding this comment.
Let's use "Time delta" in the title here?
|
Thank you! Looking forward to less merge conflicts (going to introduce plenty of new ones though now that I'm starting to work on the 0.5 branch).
I feel that deprecating the type would cause a lot of churn while bringing little benefit. New code can start using |
We have discussed something like this many times. Reasons to rename
DurationtoTimeDelta:Durationis usually understood to be strictly positive. Our type can be both positive and negative. That makes it more flexible, which is a good thing for a date and time library. The nameTimeDeltacan better represent a signed value.Durationtype unsigned, as that is a better match for system APIs. We want to avoid confusion with that type.OldDurationwe currently use as an alias in our documentation to ease the confusion a little is just sad (and not really helping).TimeDelta, and we expect users to eventually migrate. By making the name available now we can ease the migration a little when the time comes.The old name
Durationwill remain available as a type alias forTimeDelta, so this is not a breaking change.