Skip to content

Commit e20fabb

Browse files
authored
Rollup merge of #100294 - theli-ua:master, r=thomcc
Update Duration::as_secs doc to point to as_secs_f64/32 for including fractional part Rather than suggesting to calculate manually
2 parents 89835a0 + 63be9a9 commit e20fabb

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

library/core/src/time.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -318,19 +318,11 @@ impl Duration {
318318
/// assert_eq!(duration.as_secs(), 5);
319319
/// ```
320320
///
321-
/// To determine the total number of seconds represented by the `Duration`,
322-
/// use `as_secs` in combination with [`subsec_nanos`]:
323-
///
324-
/// ```
325-
/// use std::time::Duration;
326-
///
327-
/// let duration = Duration::new(5, 730023852);
328-
///
329-
/// assert_eq!(5.730023852,
330-
/// duration.as_secs() as f64
331-
/// + duration.subsec_nanos() as f64 * 1e-9);
332-
/// ```
321+
/// To determine the total number of seconds represented by the `Duration`
322+
/// including the fractional part, use [`as_secs_f64`] or [`as_secs_f32`]
333323
///
324+
/// [`as_secs_f32`]: Duration::as_secs_f64
325+
/// [`as_secs_f64`]: Duration::as_secs_f32
334326
/// [`subsec_nanos`]: Duration::subsec_nanos
335327
#[stable(feature = "duration", since = "1.3.0")]
336328
#[rustc_const_stable(feature = "duration_consts", since = "1.32.0")]

0 commit comments

Comments
 (0)