@@ -1084,40 +1084,42 @@ impl Duration {
10841084 ///
10851085 /// # Examples
10861086 /// ```
1087- /// #![feature(div_duration)]
10881087 /// use std::time::Duration;
10891088 ///
10901089 /// let dur1 = Duration::new(2, 700_000_000);
10911090 /// let dur2 = Duration::new(5, 400_000_000);
10921091 /// assert_eq!(dur1.div_duration_f64(dur2), 0.5);
10931092 /// ```
1094- #[ unstable ( feature = "div_duration" , issue = "63139 " ) ]
1093+ #[ stable ( feature = "div_duration" , since = "CURRENT_RUSTC_VERSION " ) ]
10951094 #[ must_use = "this returns the result of the operation, \
10961095 without modifying the original"]
10971096 #[ inline]
10981097 #[ rustc_const_unstable( feature = "duration_consts_float" , issue = "72440" ) ]
10991098 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
11011102 }
11021103
11031104 /// Divide `Duration` by `Duration` and return `f32`.
11041105 ///
11051106 /// # Examples
11061107 /// ```
1107- /// #![feature(div_duration)]
11081108 /// use std::time::Duration;
11091109 ///
11101110 /// let dur1 = Duration::new(2, 700_000_000);
11111111 /// let dur2 = Duration::new(5, 400_000_000);
11121112 /// assert_eq!(dur1.div_duration_f32(dur2), 0.5);
11131113 /// ```
1114- #[ unstable ( feature = "div_duration" , issue = "63139 " ) ]
1114+ #[ stable ( feature = "div_duration" , since = "CURRENT_RUSTC_VERSION " ) ]
11151115 #[ must_use = "this returns the result of the operation, \
11161116 without modifying the original"]
11171117 #[ inline]
11181118 #[ rustc_const_unstable( feature = "duration_consts_float" , issue = "72440" ) ]
11191119 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
11211123 }
11221124}
11231125
0 commit comments