Skip to content

Commit c6b3068

Browse files
committed
Add Timer::pause
Closes #238 Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
1 parent be049a8 commit c6b3068

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,12 @@ impl Timer {
443443
}
444444
}
445445

446+
/// Pause the timer so it never fires again until a new interval or instant is set.
447+
pub fn pause(&mut self) {
448+
self.clear();
449+
self.when = None;
450+
}
451+
446452
/// Helper function to clear the current timer.
447453
fn clear(&mut self) {
448454
if let (Some(when), Some((id, _))) = (self.when, self.id_and_waker.as_ref()) {

0 commit comments

Comments
 (0)