- Added a description of internal storage and permissable range to the
Duration type.
- Adjusted formatting of `Duration` in a number of related function
Rustdoc blocks, to aid readability.
- Clarified comments for Duration::num_milliseconds().
- Added a new Duration::try_milliseconds() function, to attempt to
create a new milliseconds-based Duration, and return None if it
fails, based on checking against MAX and MIN. Currently, failure can
only happen for exactly one value, which is i64::MIN.
- Updated Duration::milliseconds() to call try_milliseconds() and
panic if None is returned. Although panicking in production code and
especially library code is bad, this is in keeping with current
Chrono behaviour. Note that this function is now no longer const.
- Updated the Duration::milliseconds() documentation to make it clear
that it now panics.
- Added documentation to Duration::microseconds() and nanoseconds() to
make it clear that they are infallible.
- All tests now pass, including the one previously ignored.
- Added Panics and Errors sections where appropriate, as these are
generally-expected and help draw attention to the fact that the
standard (i.e. non-try) constructors can panic. The Errors section
for the try constructors is common practice when returning None for
overflow situations as well as for functions actually returning a
Result.
- Added an further explanation of the behaviour of the seconds()
constructor.
- Minor additional readability edits.
- Added tests for creating the maximum and minimum allowable values of
Durations having a magnitude of seconds, testing the limits plus one
value beyond the limits in both directions. These tests all pass.
- Expanded the tests for creating the maximum and minimum allowable
values of Durations having a magnitude of milliseconds. These tests
examine the results in more detail, document what is being tested,
and also test one value beyond the limits in both directions.
Notably, the test for Duration::milliseconds() construction for
i64::MIN currently fails, as it is erroneously allowed. This test is
ignored for now, until the fix is applied.
- Expanded the tests for creating the maximum and minimum allowable
values of Durations having a magnitude of microseconds and
nanoseconds. These tests examine the results in more detail,
document what is being tested, and also test one value beyond the
limits in both directions. They also test the maximum reportable
value from .num_*() and the maximum storable value of the Duration
separately.
- Separated out the tests for MAX and MIN, for clarity.
- Added additional tests for addition and subtraction operations on
Durations, ensuring that equivalent tests are performed against both
operations, such as adding and subtracting zero, adding and
subtracting one nanosecond, and others.
- Added tests for greater-than and less-than comparison of two
Durations, to ensure that internal representation of partial seconds
is correctly ordered.