From ebb40edd0e5082d4adc2f798dcad6b4d62ed357b Mon Sep 17 00:00:00 2001 From: Joscha Date: Fri, 20 Jan 2023 17:16:09 +0100 Subject: [PATCH] Relax trait bounds on Replies methods --- src/replies.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/replies.rs b/src/replies.rs index 59ffb58..8d3cd91 100644 --- a/src/replies.rs +++ b/src/replies.rs @@ -49,8 +49,7 @@ pub struct Replies { pending: HashMap>, } -// TODO Relax bounds -impl Replies { +impl Replies { pub fn new(timeout: Duration) -> Self { Self { timeout, @@ -62,7 +61,10 @@ impl Replies { self.timeout } - pub fn wait_for(&mut self, id: I) -> PendingReply { + pub fn wait_for(&mut self, id: I) -> PendingReply + where + I: Eq + Hash, + { let (tx, rx) = oneshot::channel(); self.pending.insert(id, tx); PendingReply { @@ -71,7 +73,10 @@ impl Replies { } } - pub fn complete(&mut self, id: &I, result: R) { + pub fn complete(&mut self, id: &I, result: R) + where + I: Eq + Hash, + { if let Some(tx) = self.pending.remove(id) { let _ = tx.send(result); }