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.
2 parents 5eaf7c8 + 616f421 commit aa0dee8Copy full SHA for aa0dee8
src/lib.rs
@@ -114,6 +114,14 @@ pub struct Timer {
114
}
115
116
impl Timer {
117
+ /// Creates a timer that expires at the specified instant in time.
118
+ pub fn at(when: Instant) -> Timer {
119
+ Timer {
120
+ id_and_waker: None,
121
+ when,
122
+ }
123
124
+
125
/// Creates a timer that expires after the given duration of time.
126
///
127
/// # Examples
@@ -127,11 +135,8 @@ impl Timer {
135
/// # });
128
136
/// ```
129
137
pub fn new(dur: Duration) -> Timer {
130
- Timer {
131
- id_and_waker: None,
132
- when: Instant::now() + dur,
133
- }
134
138
+ Timer::at(Instant::now() + dur)
139
140
141
/// Resets the timer to expire after the new duration of time.
142
0 commit comments