1- // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
1+ // Copyright 2012-2017 The Rust Project Developers. See the COPYRIGHT
22// file at the top-level directory of this distribution and at
33// http://rust-lang.org/COPYRIGHT.
44//
@@ -18,9 +18,10 @@ const MILLIS_PER_SEC: u64 = 1_000;
1818/// A `Duration` type to represent a span of time, typically used for system
1919/// timeouts.
2020///
21- /// Each `Duration` is composed of a number of seconds and nanosecond precision.
22- /// APIs binding a system timeout will typically round up the nanosecond
23- /// precision if the underlying system does not support that level of precision.
21+ /// Each `Duration` is composed of a whole number of seconds and a fractional part
22+ /// represented in nanoseconds. If the underlying system does not support
23+ /// nanosecond-level precision, APIs binding a system timeout will typically round up
24+ /// the number of nanoseconds.
2425///
2526/// `Duration`s implement many common traits, including [`Add`], [`Sub`], and other
2627/// [`ops`] traits.
@@ -50,11 +51,11 @@ pub struct Duration {
5051}
5152
5253impl Duration {
53- /// Creates a new `Duration` from the specified number of seconds and
54- /// additional nanosecond precision .
54+ /// Creates a new `Duration` from the specified number of whole seconds and
55+ /// additional nanoseconds .
5556 ///
56- /// If the nanoseconds is greater than 1 billion (the number of nanoseconds
57- /// in a second), then it will carry over into the seconds provided.
57+ /// If the number of nanoseconds is greater than 1 billion (the number of
58+ /// nanoseconds in a second), then it will carry over into the seconds provided.
5859 ///
5960 /// # Panics
6061 ///
@@ -77,7 +78,7 @@ impl Duration {
7778 Duration { secs : secs, nanos : nanos }
7879 }
7980
80- /// Creates a new `Duration` from the specified number of seconds.
81+ /// Creates a new `Duration` from the specified number of whole seconds.
8182 ///
8283 /// # Examples
8384 ///
@@ -115,10 +116,10 @@ impl Duration {
115116 Duration { secs : secs, nanos : nanos }
116117 }
117118
118- /// Returns the number of whole seconds represented by this `Duration`.
119+ /// Returns the number of _whole_ seconds contained by this `Duration`.
119120 ///
120- /// The extra precision represented by this duration is ignored (i.e. extra
121- /// nanoseconds are not represented in the returned value) .
121+ /// The returned value does not include the fractional (nanosecond) part of the
122+ /// duration, which can be obtained using [`subsec_nanos`] .
122123 ///
123124 /// # Examples
124125 ///
@@ -147,7 +148,7 @@ impl Duration {
147148 #[ inline]
148149 pub fn as_secs ( & self ) -> u64 { self . secs }
149150
150- /// Returns the nanosecond precision represented by this `Duration`.
151+ /// Returns the fractional part of this `Duration`, in nanoseconds .
151152 ///
152153 /// This method does **not** return the length of the duration when
153154 /// represented by nanoseconds. The returned number always represents a
@@ -159,7 +160,8 @@ impl Duration {
159160 /// use std::time::Duration;
160161 ///
161162 /// let duration = Duration::from_millis(5010);
162- /// assert_eq!(duration.subsec_nanos(), 10000000);
163+ /// assert_eq!(duration.as_secs(), 5);
164+ /// assert_eq!(duration.subsec_nanos(), 10_000_000);
163165 /// ```
164166 #[ stable( feature = "duration" , since = "1.3.0" ) ]
165167 #[ inline]
0 commit comments