We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8887396 commit 43baa2cCopy full SHA for 43baa2c
src/libcore/time.rs
@@ -263,6 +263,22 @@ impl Duration {
263
#[inline]
264
pub fn subsec_nanos(&self) -> u32 { self.nanos }
265
266
+ /// Returns the total number of nanoseconds contained by this `Duration`.
267
+ ///
268
+ /// # Examples
269
270
+ /// ```
271
+ /// use std::time::Duration;
272
273
+ /// let duration = Duration::new(5, 730023852);
274
+ /// assert_eq!(duration.as_nanos(), 5730023852);
275
276
+ #[unstable(feature = "duration_nanos", issue = "0")]
277
+ #[inline]
278
+ pub fn as_nanos(&self) -> u128 {
279
+ self.secs as u128 * 1000_000_000 + self.nanos as u128
280
+ }
281
+
282
/// Checked `Duration` addition. Computes `self + other`, returning [`None`]
283
/// if overflow occurred.
284
///
0 commit comments