From 23b0aee5ddde5eca9fc10e8a8b90414c2a9cab4f Mon Sep 17 00:00:00 2001 From: Toby Lawrence Date: Tue, 31 Aug 2021 17:09:10 -0400 Subject: [PATCH] tokio-util: expose key used in DelayQueue's Expired (#4081) Signed-off-by: Toby Lawrence --- tokio-util/src/time/delay_queue.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tokio-util/src/time/delay_queue.rs b/tokio-util/src/time/delay_queue.rs index bb742165e17..e9ab25a1679 100644 --- a/tokio-util/src/time/delay_queue.rs +++ b/tokio-util/src/time/delay_queue.rs @@ -176,7 +176,7 @@ pub struct Expired { /// /// [`DelayQueue`]: struct@DelayQueue /// [`DelayQueue::insert`]: method@DelayQueue::insert -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] pub struct Key { index: usize, } @@ -921,4 +921,9 @@ impl Expired { pub fn deadline(&self) -> Instant { self.deadline } + + /// Returns the key that the expiration is indexed by. + pub fn key(&self) -> Key { + self.key + } }