Răsfoiți Sursa

chore: Clippy lints

parazyd 3 ani în urmă
părinte
comite
0ba9740b84

+ 4 - 5
bin/darkirc/src/irc/client.rs

@@ -90,8 +90,8 @@ impl<C: AsyncRead + AsyncWrite + Send + Unpin + 'static> IrcClient<C> {
                 // Process msg from View or other client connnected to the same irc server
                 msg = self.subscription.receive().fuse() => {
                     match msg {
-                        ClientSubMsg::Privmsg(mut m) => {
-                            if let Err(e) = self.process_msg(&mut m).await {
+                        ClientSubMsg::Privmsg(m) => {
+                            if let Err(e) = self.process_msg(&m).await {
                                 error!("[CLIENT {}] Process msg: {}",  self.address, e);
                                 break
                             }
@@ -162,7 +162,7 @@ impl<C: AsyncRead + AsyncWrite + Send + Unpin + 'static> IrcClient<C> {
         }
     }
 
-    pub async fn process_msg(&mut self, msg: &mut PrivMsgEvent) -> Result<()> {
+    pub async fn process_msg(&mut self, msg: &PrivMsgEvent) -> Result<()> {
         debug!("[CLIENT {}] msg from View: {:?}", self.address, msg.to_string());
 
         let mut msg = msg.clone();
@@ -608,8 +608,7 @@ impl<C: AsyncRead + AsyncWrite + Send + Unpin + 'static> IrcClient<C> {
         hash_vec.sort_by(|a, b| a.timestamp.0.cmp(&b.timestamp.0));
 
         for event in hash_vec {
-            let mut action = event.action.clone();
-            if let Err(e) = self.process_msg(&mut action).await {
+            if let Err(e) = self.process_msg(&event.action).await {
                 error!("[CLIENT {}] Process msg: {}", self.address, e);
                 continue
             }

+ 2 - 2
bin/drk/src/wallet_dao.rs

@@ -533,8 +533,8 @@ impl Drk {
     /// List DAO(s) imported in the wallet. If an ID is given, just print the
     /// metadata for that specific one, if found.
     pub async fn dao_list(&self, dao_id: Option<u64>) -> Result<()> {
-        if dao_id.is_some() {
-            return self.dao_list_single(dao_id.unwrap()).await
+        if let Some(dao_id) = dao_id {
+            return self.dao_list_single(dao_id).await
         }
 
         let daos = self.get_daos().await?;

+ 1 - 3
src/geode/mod.rs

@@ -380,9 +380,7 @@ impl Geode {
             Ok(v) => v,
             Err(e) => match e {
                 // If the file is not found, return according error.
-                Error::Io(err) if err == std::io::ErrorKind::NotFound => {
-                    return Err(Error::GeodeFileNotFound)
-                }
+                Error::Io(std::io::ErrorKind::NotFound) => return Err(Error::GeodeFileNotFound),
                 // Anything else should tell the client to do garbage collection
                 _ => return Err(Error::GeodeNeedsGc),
             },

+ 2 - 2
src/net/protocol/protocol_jobs_manager.rs

@@ -58,9 +58,9 @@ impl ProtocolJobsManager {
     async fn handle_stop(self: Arc<Self>) {
         let stop_sub = self.channel.subscribe_stop().await;
 
-        if stop_sub.is_ok() {
+        if let Ok(stop_sub) = stop_sub {
             // Wait for the stop signal
-            stop_sub.unwrap().receive().await;
+            stop_sub.receive().await;
         }
 
         self.close_all_tasks().await

+ 3 - 5
src/net/session/inbound_session.rs

@@ -57,11 +57,9 @@ pub struct InboundInfo {
 
 impl InboundInfo {
     async fn dnet_info(&self, p2p: P2pPtr) -> Option<Self> {
-        let Some(ref addr) = self.addr else { return None };
-
-        let Some(chan) = p2p.channels().lock().await.get(addr).cloned() else { return None };
-
-        Some(Self { addr: self.addr.clone(), channel: Some(chan.dnet_info().await) })
+        let addr = self.addr.clone()?;
+        let chan = p2p.channels().lock().await.get(&addr).cloned()?;
+        Some(Self { addr: Some(addr), channel: Some(chan.dnet_info().await) })
     }
 }
 

+ 2 - 2
src/net/session/mod.rs

@@ -54,9 +54,9 @@ pub async fn remove_sub_on_stop(p2p: P2pPtr, channel: ChannelPtr) {
     // Subscribe to stop events
     let stop_sub = channel.clone().subscribe_stop().await;
 
-    if stop_sub.is_ok() {
+    if let Ok(stop_sub) = stop_sub {
         // Wait for a stop event
-        stop_sub.unwrap().receive().await;
+        stop_sub.receive().await;
     }
 
     debug!(

+ 3 - 9
src/net/session/outbound_session.rs

@@ -86,15 +86,9 @@ pub struct OutboundInfo {
 
 impl OutboundInfo {
     async fn dnet_info(&self, p2p: P2pPtr) -> Option<Self> {
-        let Some(ref addr) = self.addr else { return None };
-
-        let Some(chan) = p2p.channels().lock().await.get(addr).cloned() else { return None };
-
-        Some(Self {
-            addr: self.addr.clone(),
-            channel: Some(chan.dnet_info().await),
-            state: self.state,
-        })
+        let addr = self.addr.clone()?;
+        let chan = p2p.channels().lock().await.get(&addr).cloned()?;
+        Some(Self { addr: Some(addr), channel: Some(chan.dnet_info().await), state: self.state })
     }
 }
 

+ 2 - 2
src/net/transport/tcp.rs

@@ -71,8 +71,8 @@ impl TcpDialer {
         debug!(target: "net::tcp::do_dial", "Dialing {} with TCP...", socket_addr);
         let socket = self.create_socket(socket_addr).await?;
 
-        let connection = if timeout.is_some() {
-            socket.connect_timeout(&socket_addr.into(), timeout.unwrap())
+        let connection = if let Some(timeout) = timeout {
+            socket.connect_timeout(&socket_addr.into(), timeout)
         } else {
             socket.connect(&socket_addr.into())
         };

+ 1 - 1
src/rpc/server.rs

@@ -49,7 +49,7 @@ async fn accept(
         let mut buf = vec![0; 1024 * 8192];
 
         let n = match stream.read(&mut buf).await {
-            Ok(n) if n == 0 => {
+            Ok(0) => {
                 debug!(target: "rpc::server", "Closed connection for {}", peer_addr);
                 break
             }