about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-08-09 07:06:01 +0200
committerGitHub <noreply@github.com>2022-08-09 07:06:01 +0200
commite20fabb6d573d503d2863fb7619257a0701cc293 (patch)
tree5c12cfcda188ff0be71f5ebce5fed8d652a357d3
parent89835a018e3f013f9e870dcbe5c64ad65ae99cce (diff)
parent63be9a95b66ddb097a585ca58b23e291e40706e0 (diff)
downloadrust-e20fabb6d573d503d2863fb7619257a0701cc293.tar.gz
rust-e20fabb6d573d503d2863fb7619257a0701cc293.zip
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
-rw-r--r--library/core/src/time.rs16
1 files changed, 4 insertions, 12 deletions
diff --git a/library/core/src/time.rs b/library/core/src/time.rs
index 756f1a1663c..48353756741 100644
--- a/library/core/src/time.rs
+++ b/library/core/src/time.rs
@@ -318,19 +318,11 @@ impl Duration {
     /// assert_eq!(duration.as_secs(), 5);
     /// ```
     ///
-    /// To determine the total number of seconds represented by the `Duration`,
-    /// use `as_secs` in combination with [`subsec_nanos`]:
-    ///
-    /// ```
-    /// use std::time::Duration;
-    ///
-    /// let duration = Duration::new(5, 730023852);
-    ///
-    /// assert_eq!(5.730023852,
-    ///            duration.as_secs() as f64
-    ///            + duration.subsec_nanos() as f64 * 1e-9);
-    /// ```
+    /// To determine the total number of seconds represented by the `Duration`
+    /// including the fractional part, use [`as_secs_f64`] or [`as_secs_f32`]
     ///
+    /// [`as_secs_f32`]: Duration::as_secs_f64
+    /// [`as_secs_f64`]: Duration::as_secs_f32
     /// [`subsec_nanos`]: Duration::subsec_nanos
     #[stable(feature = "duration", since = "1.3.0")]
     #[rustc_const_stable(feature = "duration_consts", since = "1.32.0")]