Skip to content

Commit be8bbb0

Browse files
committed
Auto merge of #62756 - newpavlov:stabilize_dur_float, r=alexcrichton
Stabilize duration_float Closes: #54361
2 parents 0ff76ad + 4281e61 commit be8bbb0

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

src/libcore/time.rs

+14-22
Original file line numberDiff line numberDiff line change
@@ -505,15 +505,14 @@ impl Duration {
505505
///
506506
/// # Examples
507507
/// ```
508-
/// #![feature(duration_float)]
509508
/// use std::time::Duration;
510509
///
511510
/// let dur = Duration::new(2, 700_000_000);
512511
/// assert_eq!(dur.as_secs_f64(), 2.7);
513512
/// ```
514-
#[unstable(feature = "duration_float", issue = "54361")]
513+
#[stable(feature = "duration_float", since = "1.38.0")]
515514
#[inline]
516-
pub const fn as_secs_f64(&self) -> f64 {
515+
pub fn as_secs_f64(&self) -> f64 {
517516
(self.secs as f64) + (self.nanos as f64) / (NANOS_PER_SEC as f64)
518517
}
519518

@@ -523,15 +522,14 @@ impl Duration {
523522
///
524523
/// # Examples
525524
/// ```
526-
/// #![feature(duration_float)]
527525
/// use std::time::Duration;
528526
///
529527
/// let dur = Duration::new(2, 700_000_000);
530528
/// assert_eq!(dur.as_secs_f32(), 2.7);
531529
/// ```
532-
#[unstable(feature = "duration_float", issue = "54361")]
530+
#[stable(feature = "duration_float", since = "1.38.0")]
533531
#[inline]
534-
pub const fn as_secs_f32(&self) -> f32 {
532+
pub fn as_secs_f32(&self) -> f32 {
535533
(self.secs as f32) + (self.nanos as f32) / (NANOS_PER_SEC as f32)
536534
}
537535

@@ -543,13 +541,12 @@ impl Duration {
543541
///
544542
/// # Examples
545543
/// ```
546-
/// #![feature(duration_float)]
547544
/// use std::time::Duration;
548545
///
549546
/// let dur = Duration::from_secs_f64(2.7);
550547
/// assert_eq!(dur, Duration::new(2, 700_000_000));
551548
/// ```
552-
#[unstable(feature = "duration_float", issue = "54361")]
549+
#[stable(feature = "duration_float", since = "1.38.0")]
553550
#[inline]
554551
pub fn from_secs_f64(secs: f64) -> Duration {
555552
const MAX_NANOS_F64: f64 =
@@ -579,13 +576,12 @@ impl Duration {
579576
///
580577
/// # Examples
581578
/// ```
582-
/// #![feature(duration_float)]
583579
/// use std::time::Duration;
584580
///
585581
/// let dur = Duration::from_secs_f32(2.7);
586582
/// assert_eq!(dur, Duration::new(2, 700_000_000));
587583
/// ```
588-
#[unstable(feature = "duration_float", issue = "54361")]
584+
#[stable(feature = "duration_float", since = "1.38.0")]
589585
#[inline]
590586
pub fn from_secs_f32(secs: f32) -> Duration {
591587
const MAX_NANOS_F32: f32 =
@@ -614,14 +610,13 @@ impl Duration {
614610
///
615611
/// # Examples
616612
/// ```
617-
/// #![feature(duration_float)]
618613
/// use std::time::Duration;
619614
///
620615
/// let dur = Duration::new(2, 700_000_000);
621616
/// assert_eq!(dur.mul_f64(3.14), Duration::new(8, 478_000_000));
622617
/// assert_eq!(dur.mul_f64(3.14e5), Duration::new(847_800, 0));
623618
/// ```
624-
#[unstable(feature = "duration_float", issue = "54361")]
619+
#[stable(feature = "duration_float", since = "1.38.0")]
625620
#[inline]
626621
pub fn mul_f64(self, rhs: f64) -> Duration {
627622
Duration::from_secs_f64(rhs * self.as_secs_f64())
@@ -634,7 +629,6 @@ impl Duration {
634629
///
635630
/// # Examples
636631
/// ```
637-
/// #![feature(duration_float)]
638632
/// use std::time::Duration;
639633
///
640634
/// let dur = Duration::new(2, 700_000_000);
@@ -643,7 +637,7 @@ impl Duration {
643637
/// assert_eq!(dur.mul_f32(3.14), Duration::new(8, 478_000_640));
644638
/// assert_eq!(dur.mul_f32(3.14e5), Duration::new(847799, 969_120_256));
645639
/// ```
646-
#[unstable(feature = "duration_float", issue = "54361")]
640+
#[stable(feature = "duration_float", since = "1.38.0")]
647641
#[inline]
648642
pub fn mul_f32(self, rhs: f32) -> Duration {
649643
Duration::from_secs_f32(rhs * self.as_secs_f32())
@@ -656,15 +650,14 @@ impl Duration {
656650
///
657651
/// # Examples
658652
/// ```
659-
/// #![feature(duration_float)]
660653
/// use std::time::Duration;
661654
///
662655
/// let dur = Duration::new(2, 700_000_000);
663656
/// assert_eq!(dur.div_f64(3.14), Duration::new(0, 859_872_611));
664657
/// // note that truncation is used, not rounding
665658
/// assert_eq!(dur.div_f64(3.14e5), Duration::new(0, 8_598));
666659
/// ```
667-
#[unstable(feature = "duration_float", issue = "54361")]
660+
#[stable(feature = "duration_float", since = "1.38.0")]
668661
#[inline]
669662
pub fn div_f64(self, rhs: f64) -> Duration {
670663
Duration::from_secs_f64(self.as_secs_f64() / rhs)
@@ -677,7 +670,6 @@ impl Duration {
677670
///
678671
/// # Examples
679672
/// ```
680-
/// #![feature(duration_float)]
681673
/// use std::time::Duration;
682674
///
683675
/// let dur = Duration::new(2, 700_000_000);
@@ -687,7 +679,7 @@ impl Duration {
687679
/// // note that truncation is used, not rounding
688680
/// assert_eq!(dur.div_f32(3.14e5), Duration::new(0, 8_598));
689681
/// ```
690-
#[unstable(feature = "duration_float", issue = "54361")]
682+
#[stable(feature = "duration_float", since = "1.38.0")]
691683
#[inline]
692684
pub fn div_f32(self, rhs: f32) -> Duration {
693685
Duration::from_secs_f32(self.as_secs_f32() / rhs)
@@ -697,14 +689,14 @@ impl Duration {
697689
///
698690
/// # Examples
699691
/// ```
700-
/// #![feature(duration_float)]
692+
/// #![feature(div_duration)]
701693
/// use std::time::Duration;
702694
///
703695
/// let dur1 = Duration::new(2, 700_000_000);
704696
/// let dur2 = Duration::new(5, 400_000_000);
705697
/// assert_eq!(dur1.div_duration_f64(dur2), 0.5);
706698
/// ```
707-
#[unstable(feature = "duration_float", issue = "54361")]
699+
#[unstable(feature = "div_duration", issue = "63139")]
708700
#[inline]
709701
pub fn div_duration_f64(self, rhs: Duration) -> f64 {
710702
self.as_secs_f64() / rhs.as_secs_f64()
@@ -714,14 +706,14 @@ impl Duration {
714706
///
715707
/// # Examples
716708
/// ```
717-
/// #![feature(duration_float)]
709+
/// #![feature(div_duration)]
718710
/// use std::time::Duration;
719711
///
720712
/// let dur1 = Duration::new(2, 700_000_000);
721713
/// let dur2 = Duration::new(5, 400_000_000);
722714
/// assert_eq!(dur1.div_duration_f32(dur2), 0.5);
723715
/// ```
724-
#[unstable(feature = "duration_float", issue = "54361")]
716+
#[unstable(feature = "div_duration", issue = "63139")]
725717
#[inline]
726718
pub fn div_duration_f32(self, rhs: Duration) -> f32 {
727719
self.as_secs_f32() / rhs.as_secs_f32()

0 commit comments

Comments
 (0)