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 afabed9 commit 616f421Copy full SHA for 616f421
src/lib.rs
@@ -68,6 +68,14 @@ pub struct Timer {
68
}
69
70
impl Timer {
71
+ /// Creates a timer that expires at the specified instant in time.
72
+ pub fn at(when: Instant) -> Timer {
73
+ Timer {
74
+ id_and_waker: None,
75
+ when,
76
+ }
77
78
+
79
/// Creates a timer that expires after the given duration of time.
80
///
81
/// # Examples
@@ -81,11 +89,8 @@ impl Timer {
89
/// # });
82
90
/// ```
83
91
pub fn new(dur: Duration) -> Timer {
84
- Timer {
85
- id_and_waker: None,
86
- when: Instant::now() + dur,
87
- }
88
92
+ Timer::at(Instant::now() + dur)
93
94
95
/// Resets the timer to expire after the new duration of time.
96
0 commit comments