Skip to content

Commit 7f7a2e9

Browse files
author
Stjepan Glavina
committed
Add duration constants
1 parent 433ef82 commit 7f7a2e9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/libcore/time.rs

+16
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ const MILLIS_PER_SEC: u64 = 1_000;
2323
const MICROS_PER_SEC: u64 = 1_000_000;
2424
const MAX_NANOS_F64: f64 = ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f64;
2525

26+
/// The duration of one second.
27+
#[unstable(feature = "duration_constants", issue = "0")]
28+
pub const SECOND: Duration = Duration::from_secs(1);
29+
30+
/// The duration of one millisecond.
31+
#[unstable(feature = "duration_constants", issue = "0")]
32+
pub const MILLISECOND: Duration = Duration::from_millis(1);
33+
34+
/// The duration of one microsecond.
35+
#[unstable(feature = "duration_constants", issue = "0")]
36+
pub const MICROSECOND: Duration = Duration::from_micros(1);
37+
38+
/// The duration of one nanosecond.
39+
#[unstable(feature = "duration_constants", issue = "0")]
40+
pub const NANOSECOND: Duration = Duration::from_nanos(1);
41+
2642
/// A `Duration` type to represent a span of time, typically used for system
2743
/// timeouts.
2844
///

0 commit comments

Comments
 (0)