Rollup merge of #124667 - newpavlov:stabilize_div_duration, r=jhpratt · model-checking/verify-rust-std@bf3ca98 (original) (raw)
`@@ -1084,40 +1084,42 @@ impl Duration {
`
1084
1084
`///
`
1085
1085
`/// # Examples
`
1086
1086
```` /// ```
`1087`
``
`-
/// #![feature(div_duration)]
`
`1088`
`1087`
`/// use std::time::Duration;
`
`1089`
`1088`
`///
`
`1090`
`1089`
`/// let dur1 = Duration::new(2, 700_000_000);
`
`1091`
`1090`
`/// let dur2 = Duration::new(5, 400_000_000);
`
`1092`
`1091`
`/// assert_eq!(dur1.div_duration_f64(dur2), 0.5);
`
`1093`
`1092`
```` /// ```
1094
``
`-
#[unstable(feature = "div_duration", issue = "63139")]
`
``
1093
`+
#[stable(feature = "div_duration", since = "CURRENT_RUSTC_VERSION")]
`
1095
1094
`#[must_use = "this returns the result of the operation, \
`
1096
1095
` without modifying the original"]
`
1097
1096
`#[inline]
`
1098
1097
`#[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")]
`
1099
1098
`pub const fn div_duration_f64(self, rhs: Duration) -> f64 {
`
1100
``
`-
self.as_secs_f64() / rhs.as_secs_f64()
`
``
1099
`+
let self_nanos = (self.secs as f64) * (NANOS_PER_SEC as f64) + (self.nanos.0 as f64);
`
``
1100
`+
let rhs_nanos = (rhs.secs as f64) * (NANOS_PER_SEC as f64) + (rhs.nanos.0 as f64);
`
``
1101
`+
self_nanos / rhs_nanos
`
1101
1102
`}
`
1102
1103
``
1103
1104
`` /// Divide Duration
by Duration
and return f32
.
``
1104
1105
`///
`
1105
1106
`/// # Examples
`
1106
1107
```` /// ```
`1107`
``
`-
/// #![feature(div_duration)]
`
`1108`
`1108`
`/// use std::time::Duration;
`
`1109`
`1109`
`///
`
`1110`
`1110`
`/// let dur1 = Duration::new(2, 700_000_000);
`
`1111`
`1111`
`/// let dur2 = Duration::new(5, 400_000_000);
`
`1112`
`1112`
`/// assert_eq!(dur1.div_duration_f32(dur2), 0.5);
`
`1113`
`1113`
```` /// ```
1114
``
`-
#[unstable(feature = "div_duration", issue = "63139")]
`
``
1114
`+
#[stable(feature = "div_duration", since = "CURRENT_RUSTC_VERSION")]
`
1115
1115
`#[must_use = "this returns the result of the operation, \
`
1116
1116
` without modifying the original"]
`
1117
1117
`#[inline]
`
1118
1118
`#[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")]
`
1119
1119
`pub const fn div_duration_f32(self, rhs: Duration) -> f32 {
`
1120
``
`-
self.as_secs_f32() / rhs.as_secs_f32()
`
``
1120
`+
let self_nanos = (self.secs as f32) * (NANOS_PER_SEC as f32) + (self.nanos.0 as f32);
`
``
1121
`+
let rhs_nanos = (rhs.secs as f32) * (NANOS_PER_SEC as f32) + (rhs.nanos.0 as f32);
`
``
1122
`+
self_nanos / rhs_nanos
`
1121
1123
`}
`
1122
1124
`}
`
1123
1125
``