From: Lizzy Fleckenstein Date: Fri, 6 Jan 2023 23:49:04 +0000 (+0100) Subject: clippy X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=9cf950fd1618dc888b6271346386acc64c282177;p=mt_rudp.git clippy --- diff --git a/Cargo.toml b/Cargo.toml index 1805a8c..53ab291 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,4 +12,4 @@ tokio = { version = "1.23.0", features = ["sync", "time", "net", "signal", "macr [dev-dependencies] pretty-hex = "0.3.0" -tokio = { features = ["rt-multi-thread"] } +tokio = { version = "1.23.0", features = ["rt-multi-thread"] } diff --git a/src/client.rs b/src/client.rs index e6d7e75..6785a1f 100644 --- a/src/client.rs +++ b/src/client.rs @@ -36,7 +36,7 @@ pub async fn connect(addr: &str) -> io::Result<(RudpSender, RudpReceiver let sock = Arc::new(net::UdpSocket::bind("0.0.0.0:0").await?); sock.connect(addr).await?; - Ok(new( + new( PeerID::Srv as u16, PeerID::Nil as u16, Sender { @@ -44,5 +44,5 @@ pub async fn connect(addr: &str) -> io::Result<(RudpSender, RudpReceiver }, Receiver { sock }, ) - .await?) + .await } diff --git a/src/error.rs b/src/error.rs index e048120..55566fa 100644 --- a/src/error.rs +++ b/src/error.rs @@ -47,7 +47,7 @@ impl fmt::Display for Error { write!(f, "rudp: ")?; match self { - IoError(err) => write!(f, "IO error: {}", err), + IoError(err) => write!(f, "IO error: {err}"), InvalidProtoId(id) => write!(f, "invalid protocol ID: {id}"), InvalidChannel(ch) => write!(f, "invalid channel: {ch}"), InvalidType(tp) => write!(f, "invalid type: {tp}"), diff --git a/src/recv.rs b/src/recv.rs index e3d3e6b..e685c9c 100644 --- a/src/recv.rs +++ b/src/recv.rs @@ -82,6 +82,7 @@ impl RecvWorker { self.pkt_tx.send(Err(RemoteDisco(to))).ok(); } + #[allow(clippy::single_match)] match e { // anon5's mt notifies the peer on timeout, C++ MT does not LocalDisco /*| RemoteDisco(true)*/ => drop( diff --git a/src/send.rs b/src/send.rs index c41ad80..3ec3c64 100644 --- a/src/send.rs +++ b/src/send.rs @@ -12,11 +12,12 @@ impl RudpSender { } impl RudpShare { + #[allow(clippy::unused_io_amount)] pub async fn send(&self, tp: PktType, pkt: Pkt<&[u8]>) -> AckResult { let mut buf = Vec::with_capacity(4 + 2 + 1 + 1 + 2 + 1 + pkt.data.len()); buf.write_u32::(PROTO_ID)?; buf.write_u16::(*self.remote_id.read().await)?; - buf.write_u8(pkt.chan as u8)?; + buf.write_u8(pkt.chan)?; let mut chan = self.chans[pkt.chan as usize].lock().await; let seqnum = chan.seqnum;