Rollup merge of #129947 - LiterallyVoid:duration-docs-digit-separators, r=tgross35

Add digit separators in `Duration` examples

``@rustbot`` label A-docs
This commit is contained in:
Matthias Krüger 2024-09-05 19:43:50 +02:00 committed by GitHub
commit 96719dbe32
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -250,7 +250,7 @@ pub const fn from_secs(secs: u64) -> Duration {
/// ```
/// use std::time::Duration;
///
/// let duration = Duration::from_millis(2569);
/// let duration = Duration::from_millis(2_569);
///
/// assert_eq!(2, duration.as_secs());
/// assert_eq!(569_000_000, duration.subsec_nanos());
@ -279,7 +279,7 @@ pub const fn from_millis(millis: u64) -> Duration {
/// let duration = Duration::from_micros(1_000_002);
///
/// assert_eq!(1, duration.as_secs());
/// assert_eq!(2000, duration.subsec_nanos());
/// assert_eq!(2_000, duration.subsec_nanos());
/// ```
#[stable(feature = "duration_from_micros", since = "1.27.0")]
#[must_use]
@ -472,7 +472,7 @@ pub const fn is_zero(&self) -> bool {
/// ```
/// use std::time::Duration;
///
/// let duration = Duration::new(5, 730023852);
/// let duration = Duration::new(5, 730_023_852);
/// assert_eq!(duration.as_secs(), 5);
/// ```
///
@ -501,7 +501,7 @@ pub const fn as_secs(&self) -> u64 {
/// ```
/// use std::time::Duration;
///
/// let duration = Duration::from_millis(5432);
/// let duration = Duration::from_millis(5_432);
/// assert_eq!(duration.as_secs(), 5);
/// assert_eq!(duration.subsec_millis(), 432);
/// ```
@ -547,7 +547,7 @@ pub const fn subsec_micros(&self) -> u32 {
/// ```
/// use std::time::Duration;
///
/// let duration = Duration::from_millis(5010);
/// let duration = Duration::from_millis(5_010);
/// assert_eq!(duration.as_secs(), 5);
/// assert_eq!(duration.subsec_nanos(), 10_000_000);
/// ```
@ -566,8 +566,8 @@ pub const fn subsec_nanos(&self) -> u32 {
/// ```
/// use std::time::Duration;
///
/// let duration = Duration::new(5, 730023852);
/// assert_eq!(duration.as_millis(), 5730);
/// let duration = Duration::new(5, 730_023_852);
/// assert_eq!(duration.as_millis(), 5_730);
/// ```
#[stable(feature = "duration_as_u128", since = "1.33.0")]
#[rustc_const_stable(feature = "duration_as_u128", since = "1.33.0")]
@ -584,8 +584,8 @@ pub const fn as_millis(&self) -> u128 {
/// ```
/// use std::time::Duration;
///
/// let duration = Duration::new(5, 730023852);
/// assert_eq!(duration.as_micros(), 5730023);
/// let duration = Duration::new(5, 730_023_852);
/// assert_eq!(duration.as_micros(), 5_730_023);
/// ```
#[stable(feature = "duration_as_u128", since = "1.33.0")]
#[rustc_const_stable(feature = "duration_as_u128", since = "1.33.0")]
@ -602,8 +602,8 @@ pub const fn as_micros(&self) -> u128 {
/// ```
/// use std::time::Duration;
///
/// let duration = Duration::new(5, 730023852);
/// assert_eq!(duration.as_nanos(), 5730023852);
/// let duration = Duration::new(5, 730_023_852);
/// assert_eq!(duration.as_nanos(), 5_730_023_852);
/// ```
#[stable(feature = "duration_as_u128", since = "1.33.0")]
#[rustc_const_stable(feature = "duration_as_u128", since = "1.33.0")]
@ -879,7 +879,7 @@ pub const fn as_secs_f32(&self) -> f32 {
/// use std::time::Duration;
///
/// let dur = Duration::new(2, 345_678_000);
/// assert_eq!(dur.as_millis_f64(), 2345.678);
/// assert_eq!(dur.as_millis_f64(), 2_345.678);
/// ```
#[unstable(feature = "duration_millis_float", issue = "122451")]
#[must_use]
@ -900,7 +900,7 @@ pub const fn as_millis_f64(&self) -> f64 {
/// use std::time::Duration;
///
/// let dur = Duration::new(2, 345_678_000);
/// assert_eq!(dur.as_millis_f32(), 2345.678);
/// assert_eq!(dur.as_millis_f32(), 2_345.678);
/// ```
#[unstable(feature = "duration_millis_float", issue = "122451")]
#[must_use]
@ -1017,7 +1017,7 @@ pub fn mul_f64(self, rhs: f64) -> Duration {
///
/// let dur = Duration::new(2, 700_000_000);
/// assert_eq!(dur.mul_f32(3.14), Duration::new(8, 478_000_641));
/// assert_eq!(dur.mul_f32(3.14e5), Duration::new(847800, 0));
/// assert_eq!(dur.mul_f32(3.14e5), Duration::new(847_800, 0));
/// ```
#[stable(feature = "duration_float", since = "1.38.0")]
#[must_use = "this returns the result of the operation, \