Skip to content

Commit 14a6dd7

Browse files
committedApr 16, 2017
use constants
1 parent b2514bf commit 14a6dd7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed
 

‎src/libstd/time/duration.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ impl Duration {
141141
/// ```
142142
#[unstable(feature = "duration_as_millis", issue = "0")]
143143
#[inline]
144-
pub fn as_millis(&self) -> u64 { self.secs * 1000 + self.nanos as u64 / 1_000_000 }
144+
pub fn as_millis(&self) -> u64 {
145+
self.secs * MILLIS_PER_SEC + (self.nanos / NANOS_PER_MILLI) as u64
146+
}
145147

146148
/// Returns the nanosecond precision represented by this `Duration`.
147149
///

0 commit comments

Comments
 (0)
Please sign in to comment.