From 163a96b0623a24924a37cc01b7bc82c4a5639a4d Mon Sep 17 00:00:00 2001 From: quininer Date: Sat, 23 Feb 2019 01:48:09 +0800 Subject: [PATCH] fix clippy --- src/client.rs | 21 +++++++++------------ src/common/mod.rs | 4 ++-- src/common/vecbuf.rs | 2 +- src/server.rs | 21 +++++++++------------ 4 files changed, 21 insertions(+), 27 deletions(-) diff --git a/src/client.rs b/src/client.rs index 386d242..3e9d73f 100644 --- a/src/client.rs +++ b/src/client.rs @@ -52,20 +52,17 @@ where IO: AsyncRead + AsyncWrite, #[inline] fn poll(&mut self) -> Poll { - match self { - MidHandshake::Handshaking(stream) => { - let (io, session) = stream.get_mut(); - let mut stream = Stream::new(io, session); + if let MidHandshake::Handshaking(stream) = self { + let (io, session) = stream.get_mut(); + let mut stream = Stream::new(io, session); - if stream.session.is_handshaking() { - try_nb!(stream.complete_io()); - } + if stream.session.is_handshaking() { + try_nb!(stream.complete_io()); + } - if stream.session.wants_write() { - try_nb!(stream.complete_io()); - } - }, - _ => () + if stream.session.wants_write() { + try_nb!(stream.complete_io()); + } } match mem::replace(self, MidHandshake::End) { diff --git a/src/common/mod.rs b/src/common/mod.rs index a88a278..c150189 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -84,8 +84,8 @@ impl<'a, IO: AsyncRead + AsyncWrite, S: Session> WriteTls<'a, IO, S> for Stream< } } - let mut vecbuf = V(self.io); - self.session.writev_tls(&mut vecbuf) + let mut vecio = V(self.io); + self.session.writev_tls(&mut vecio) } } diff --git a/src/common/vecbuf.rs b/src/common/vecbuf.rs index 81bec86..e550505 100644 --- a/src/common/vecbuf.rs +++ b/src/common/vecbuf.rs @@ -48,7 +48,7 @@ impl<'a, 'b> Buf for VecBuf<'a, 'b> { } } - #[cfg_attr(feature = "cargo-clippy", allow(needless_range_loop))] + #[allow(clippy::needless_range_loop)] fn bytes_vec<'c>(&'c self, dst: &mut [&'c IoVec]) -> usize { let len = cmp::min(self.inner.len() - self.pos, dst.len()); diff --git a/src/server.rs b/src/server.rs index fd02a35..67d47d3 100644 --- a/src/server.rs +++ b/src/server.rs @@ -48,20 +48,17 @@ where IO: AsyncRead + AsyncWrite, #[inline] fn poll(&mut self) -> Poll { - match self { - MidHandshake::Handshaking(stream) => { - let (io, session) = stream.get_mut(); - let mut stream = Stream::new(io, session); + if let MidHandshake::Handshaking(stream) = self { + let (io, session) = stream.get_mut(); + let mut stream = Stream::new(io, session); - if stream.session.is_handshaking() { - try_nb!(stream.complete_io()); - } + if stream.session.is_handshaking() { + try_nb!(stream.complete_io()); + } - if stream.session.wants_write() { - try_nb!(stream.complete_io()); - } - }, - _ => () + if stream.session.wants_write() { + try_nb!(stream.complete_io()); + } } match mem::replace(self, MidHandshake::End) {