(_duration: Duration, callback: impl FnOnce() + Send + 'static)
| 17 | pub type TimerId = u64; |
| 18 | |
| 19 | pub fn set_timer(_duration: Duration, callback: impl FnOnce() + Send + 'static) -> TimerId { |
| 20 | TIMERS.with(|timers| { |
| 21 | let timer_id = timers.borrow().last().map(|(id, _)| id).unwrap_or(&0) + 1; |
| 22 | timers.borrow_mut().push((timer_id, Box::new(callback))); |
| 23 | timer_id |
| 24 | }) |
| 25 | } |
| 26 | |
| 27 | pub fn clear_timer(timer_id: TimerId) { |
| 28 | TIMERS.with(|timers| { |
no test coverage detected