From 45d7cd0049b9349de428945c4a7c9b73cb0f461d Mon Sep 17 00:00:00 2001 From: Lizzy Fleckenstein Date: Wed, 15 Feb 2023 14:27:59 +0100 Subject: Use delegate instead of Deref --- src/lib.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 334692a..76f0311 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,8 +10,9 @@ mod send; pub use prelude::*; use async_trait::async_trait; +use delegate::delegate; use num_enum::TryFromPrimitive; -use std::{cell::OnceCell, collections::HashMap, io, ops, sync::Arc, time::Instant}; +use std::{cell::OnceCell, collections::HashMap, io, sync::Arc, time::Instant}; use tokio::{ sync::{mpsc, watch, Mutex, RwLock}, task::JoinSet, @@ -122,17 +123,11 @@ macro_rules! impl_share { impl_share!(RudpReceiver); impl_share!(RudpSender); -impl ops::Deref for RudpReceiver { - type Target = mpsc::UnboundedReceiver; - - fn deref(&self) -> &Self::Target { - &self.pkt_rx - } -} - -impl ops::DerefMut for RudpReceiver { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.pkt_rx +impl RudpReceiver { + delegate! { + to self.pkt_rx { + pub async fn recv(&mut self) -> Option; + } } } -- cgit v1.2.3