From 767fd15679619c9a24f5ef2a74ca01e11aea6526 Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Tue, 27 Sep 2022 21:08:49 -0700 Subject: [PATCH] Add iter_mut --- src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 1832f55..9e635d5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -292,11 +292,16 @@ impl TimerQueue { } } - /// Iterate over all scheduled timers + /// Iterate over the expiration and value of all scheduled timers pub fn iter(&self) -> impl ExactSizeIterator { self.timers.iter().map(|(_, x)| (x.expiry, &x.value)) } + /// Iterate over the expiration and value of all scheduled timers + pub fn iter_mut(&mut self) -> impl ExactSizeIterator { + self.timers.iter_mut().map(|(_, x)| (x.expiry, &mut x.value)) + } + /// Borrow the value associated with `timer` pub fn get(&self, timer: Timer) -> &T { &self.timers[timer.0].value -- knotmirror 0.0.1