rust/library/core/tests
Ralf Jung 7344f930c0
Rollup merge of #76114 - marmeladema:duration-saturating-ops, r=shepmaster
Add saturating methods for `Duration`

In some project, I needed a `saturating_add` method for `Duration`. I implemented it myself but i thought it would be a nice addition to the standard library as it matches closely with the integers types.

3 new methods have been introduced and are gated by the new `duration_saturating_ops` unstable feature:
* `Duration::saturating_add`
* `Duration::saturating_sub`
* `Duration::saturating_mul`

If have left the tracking issue to `none` for now as I want first to understand if those methods would be acceptable at all. If agreed, I'll update the PR with the tracking issue.

Further more, to match the behavior of integers types, I introduced 2 associated constants:
* `Duration::MIN`: this one is somehow a duplicate from `Duration::zero()` method, but at the time this method was added, `MIN` was rejected as it was considered a different semantic (see https://github.com/rust-lang/rust/pull/72790#issuecomment-636511743).
* `Duration::MAX`

Both have been gated by the already existing unstable feature `duration_constants`, I can introduce a new unstable feature if needed or just re-use the `duration_saturating_ops`.

We might have to decide whether:
* `MIN` should be replaced by `ZERO`?
* associated constants over methods?
2020-09-12 10:43:08 +02:00
..
fmt
hash
num flt2dec: properly handle uninitialized memory 2020-09-02 12:41:38 +02:00
alloc.rs
any.rs
array.rs Add drop check test & MaybeUninit::first_ptr_mut 2020-08-13 03:51:08 +00:00
ascii.rs Move various ui const tests to library 2020-09-04 02:35:27 +02:00
atomic.rs
bool.rs
cell.rs
char.rs
clone.rs
cmp.rs
intrinsics.rs
iter.rs Use min_specialization in libcore 2020-08-19 20:08:02 +01:00
lazy.rs Make OnceCell<T> transparent to dropck 2020-08-18 00:34:54 +02:00
lib.rs Add saturating methods for Duration 2020-09-08 00:42:56 +01:00
manually_drop.rs
mem.rs
nonzero.rs Move various ui const tests to library 2020-09-04 02:35:27 +02:00
ops.rs
option.rs Fix tests using FixedSizeArray methods (which are now shadowed) 2020-08-30 21:08:18 +02:00
pattern.rs
ptr.rs enable align_to tests in Miri 2020-08-19 10:41:51 +02:00
result.rs Fix tests using FixedSizeArray methods (which are now shadowed) 2020-08-30 21:08:18 +02:00
slice.rs Add tests for array_chunks_mut 2020-09-04 19:51:29 -07:00
str.rs
str_lossy.rs
time.rs Add saturating methods for Duration 2020-09-08 00:42:56 +01:00
tuple.rs