File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,21 @@ impl Duration {
128128 /// let duration = Duration::new(5, 730023852);
129129 /// assert_eq!(duration.as_secs(), 5);
130130 /// ```
131+ ///
132+ /// To determine the total number of seconds represented by the `Duration`,
133+ /// use `as_secs` in combination with [`subsec_nanos`]:
134+ ///
135+ /// ```
136+ /// use std::time::Duration;
137+ ///
138+ /// let duration = Duration::new(5, 730023852);
139+ ///
140+ /// assert_eq!(5.730023852,
141+ /// duration.as_secs() as f64
142+ /// + duration.subsec_nanos() as f64 * 1e-9);
143+ /// ```
144+ ///
145+ /// [`subsec_nanos`]: #method.subsec_nanos
131146 #[ stable( feature = "duration" , since = "1.3.0" ) ]
132147 #[ inline]
133148 pub fn as_secs ( & self ) -> u64 { self . secs }
You can’t perform that action at this time.
0 commit comments