Conversation
|
Maybe we can fix the confusion with |
564bfc8 to
f34af09
Compare
40ee6f2 to
6da23f4
Compare
89e8b41 to
ee4ebe3
Compare
Might be too late to chime in on this, but |
|
If a rename/alias to avoid confusion with the standard library is up for discussion:
@jtmoon79 I may not get the subtleties of the words completely. Is there one that is most appropriate for a value that can be positive and negative? |
I think all the terms proposed there are sensible for positive and negative values. I strongly prefer
Synonyms like |
6da3232 to
fdaa314
Compare
|
I'm very excited about these quality of life improvements to the duration type! (esp. finally having the I have to agree with @jtmoon79 on the new name for let dur = chrono::ChronoDuration::zero();Though I suppose most people would do |
fdaa314 to
7b97dfc
Compare
|
Added a commit to make the methods const. |
ba8dae7 to
262bdf5
Compare
src/duration.rs
Outdated
| } | ||
|
|
||
| /// Makes a new `Duration` with given number of seconds. | ||
| /// Returns None when the duration is more than `i64::MAX` milliseconds |
There was a problem hiding this comment.
Nitpick: docstring referring to specific value None (None) should format it as code, i.e. add backticks
/// Returns `None` when the duration is ...
src/duration.rs
Outdated
| Ok(StdDuration::new(self.secs as u64, self.nanos as u32)) | ||
| } | ||
|
|
||
| /// Returns true if and only if d < MIN || d > MAX |
There was a problem hiding this comment.
nitpick: why use the mathematical proof phrase "if and only if" here? I suggest wording "if", i.e.
/// Returns `true` if d < MIN || d > MAX
f17d78f to
986c25f
Compare
986c25f to
cf44a6c
Compare
Codecov Report
@@ Coverage Diff @@
## 0.4.x #1137 +/- ##
==========================================
+ Coverage 91.55% 91.57% +0.02%
==========================================
Files 38 38
Lines 17355 17385 +30
==========================================
+ Hits 15889 15920 +31
+ Misses 1466 1465 -1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
fb90ec0 to
6799e82
Compare
6799e82 to
30ed074
Compare
|
Going to hold off on this for the next week, let's discuss again around Sep 18. |
|
Would you like me to split up this PR? |
|
Yes, let's try it. Please rate limit your submissions! |
|
Haha. Okay. |
30ed074 to
56e3691
Compare
src/duration.rs
Outdated
| } | ||
|
|
||
| /// Returns `true` if d < MIN || d > MAX | ||
| const fn out_of_bounds(&self) -> bool { |
There was a problem hiding this comment.
This should be a constructor, not a method on an already constructed type.
56e3691 to
9edb340
Compare
9edb340 to
ae3827c
Compare
|
The remainder of this PR has become part of #1337. |
If we drop time 0.1 compatibility in #1095 it would be nice if we could also take care of some of the wishlist items for
Duration.Default: Consider adding a "Default" implementation to Duration #717subsec_nanosmethod: Provide access to subsecond nanos in the public interface of Duration. #154try_*builders: Fix panic in DateTime::checked_add_days #941AddAssignandSubAssign: [Feature Request]AddAssign/SubAssignimplementation tochrono::Duration#1054Three features that would be more involved and not part of this PR are:
Duration: format a Duration #197Making the remaining methods const (#309, #638) would depend on raising the MSRV as in #1080.
Based on #1095.