7

Github Tracking Issue for `Duration` saturating operations · Issue #76416 · rust...

 3 years ago
source link: https://github.com/rust-lang/rust/issues/76416
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Copy link

Contributor

marmeladema commented on Sep 6, 2020

edited

This is a tracking issue for Duration saturating operations.
The feature gate for the issue is #![feature(duration_saturating_ops)].

        impl Duration {
            pub const fn saturating_add(self, rhs: Duration) -> Duration {}
            pub const fn saturating_sub(self, rhs: Duration) -> Duration {}
            pub const fn saturating_mul(self, rhs: u32) -> Duration {}
        }

Steps

Unresolved Questions

  • Do we want associated constants similar to the ones that already exist for integer types or associated methods? (ie: Duration::MIN or Duration::min()?
  • Should Duration::MIN be replaced by Duration::zero()? They are currently equivalent but one can image a future where Duration is able to hold negative duration and thus making MIN different from zero().

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK