From 7be4b1f399281199817939f756fe69bc05646278 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 4 Apr 2018 20:24:09 -0700 Subject: [PATCH] clippy warns --- src/body.rs | 26 +++++++++++++------------- src/middleware/logger.rs | 6 +++--- src/server/h1.rs | 2 +- src/ws/frame.rs | 30 +++++++++++++++--------------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/body.rs b/src/body.rs index 97b8850c8..64123679b 100644 --- a/src/body.rs +++ b/src/body.rs @@ -281,61 +281,61 @@ mod tests { #[test] fn test_static_str() { assert_eq!(Binary::from("test").len(), 4); - assert_eq!(Binary::from("test").as_ref(), "test".as_bytes()); + assert_eq!(Binary::from("test").as_ref(), b"test"); } #[test] fn test_static_bytes() { assert_eq!(Binary::from(b"test".as_ref()).len(), 4); - assert_eq!(Binary::from(b"test".as_ref()).as_ref(), "test".as_bytes()); + assert_eq!(Binary::from(b"test".as_ref()).as_ref(), b"test"); assert_eq!(Binary::from_slice(b"test".as_ref()).len(), 4); - assert_eq!(Binary::from_slice(b"test".as_ref()).as_ref(), "test".as_bytes()); + assert_eq!(Binary::from_slice(b"test".as_ref()).as_ref(), b"test"); } #[test] fn test_vec() { assert_eq!(Binary::from(Vec::from("test")).len(), 4); - assert_eq!(Binary::from(Vec::from("test")).as_ref(), "test".as_bytes()); + assert_eq!(Binary::from(Vec::from("test")).as_ref(), b"test"); } #[test] fn test_bytes() { assert_eq!(Binary::from(Bytes::from("test")).len(), 4); - assert_eq!(Binary::from(Bytes::from("test")).as_ref(), "test".as_bytes()); + assert_eq!(Binary::from(Bytes::from("test")).as_ref(), b"test"); } #[test] fn test_ref_string() { let b = Rc::new("test".to_owned()); assert_eq!(Binary::from(&b).len(), 4); - assert_eq!(Binary::from(&b).as_ref(), "test".as_bytes()); + assert_eq!(Binary::from(&b).as_ref(), b"test"); } #[test] fn test_rc_string() { let b = Rc::new("test".to_owned()); assert_eq!(Binary::from(b.clone()).len(), 4); - assert_eq!(Binary::from(b.clone()).as_ref(), "test".as_bytes()); + assert_eq!(Binary::from(b.clone()).as_ref(), b"test"); assert_eq!(Binary::from(&b).len(), 4); - assert_eq!(Binary::from(&b).as_ref(), "test".as_bytes()); + assert_eq!(Binary::from(&b).as_ref(), b"test"); } #[test] fn test_arc_string() { let b = Arc::new("test".to_owned()); assert_eq!(Binary::from(b.clone()).len(), 4); - assert_eq!(Binary::from(b.clone()).as_ref(), "test".as_bytes()); + assert_eq!(Binary::from(b.clone()).as_ref(), b"test"); assert_eq!(Binary::from(&b).len(), 4); - assert_eq!(Binary::from(&b).as_ref(), "test".as_bytes()); + assert_eq!(Binary::from(&b).as_ref(), b"test"); } #[test] fn test_string() { let b = "test".to_owned(); assert_eq!(Binary::from(b.clone()).len(), 4); - assert_eq!(Binary::from(b.clone()).as_ref(), "test".as_bytes()); + assert_eq!(Binary::from(b.clone()).as_ref(), b"test"); assert_eq!(Binary::from(&b).len(), 4); - assert_eq!(Binary::from(&b).as_ref(), "test".as_bytes()); + assert_eq!(Binary::from(&b).as_ref(), b"test"); } #[test] @@ -351,7 +351,7 @@ mod tests { fn test_bytes_mut() { let b = BytesMut::from("test"); assert_eq!(Binary::from(b.clone()).len(), 4); - assert_eq!(Binary::from(b).as_ref(), "test".as_bytes()); + assert_eq!(Binary::from(b).as_ref(), b"test"); } #[test] diff --git a/src/middleware/logger.rs b/src/middleware/logger.rs index 48a8d3db9..32d2ef4d2 100644 --- a/src/middleware/logger.rs +++ b/src/middleware/logger.rs @@ -319,7 +319,7 @@ mod tests { } let entry_time = time::now(); let render = |fmt: &mut Formatter| { - for unit in logger.format.0.iter() { + for unit in &logger.format.0 { unit.render(fmt, &req, &resp, entry_time)?; } Ok(()) @@ -340,7 +340,7 @@ mod tests { let entry_time = time::now(); let render = |fmt: &mut Formatter| { - for unit in format.0.iter() { + for unit in &format.0 { unit.render(fmt, &req, &resp, entry_time)?; } Ok(()) @@ -357,7 +357,7 @@ mod tests { let entry_time = time::now(); let render = |fmt: &mut Formatter| { - for unit in format.0.iter() { + for unit in &format.0 { unit.render(fmt, &req, &resp, entry_time)?; } Ok(()) diff --git a/src/server/h1.rs b/src/server/h1.rs index cb2e0b049..66fdf8a7c 100644 --- a/src/server/h1.rs +++ b/src/server/h1.rs @@ -1425,7 +1425,7 @@ mod tests { let mut reader = Reader::new(); let mut req = reader_parse_ready!(reader.parse(&mut buf, &mut readbuf, &settings)); - let _ = req.payload_mut().set_read_buffer_capacity(0); + req.payload_mut().set_read_buffer_capacity(0); assert!(req.chunked().unwrap()); assert!(!req.payload().eof()); diff --git a/src/ws/frame.rs b/src/ws/frame.rs index 2afcd0358..cb3e82fe1 100644 --- a/src/ws/frame.rs +++ b/src/ws/frame.rs @@ -354,8 +354,8 @@ mod tests { use super::*; use futures::stream::once; - fn is_none(frm: Poll, ProtocolError>) -> bool { - match frm { + fn is_none(frm: &Poll, ProtocolError>) -> bool { + match *frm { Ok(Async::Ready(None)) => true, _ => false, } @@ -371,10 +371,10 @@ mod tests { #[test] fn test_parse() { let mut buf = PayloadHelper::new( - once(Ok(BytesMut::from(&[0b00000001u8, 0b00000001u8][..]).freeze()))); - assert!(is_none(Frame::parse(&mut buf, false, 1024))); + once(Ok(BytesMut::from(&[0b0000_0001u8, 0b0000_0001u8][..]).freeze()))); + assert!(is_none(&Frame::parse(&mut buf, false, 1024))); - let mut buf = BytesMut::from(&[0b00000001u8, 0b00000001u8][..]); + let mut buf = BytesMut::from(&[0b0000_0001u8, 0b0000_0001u8][..]); buf.extend(b"1"); let mut buf = PayloadHelper::new(once(Ok(buf.freeze()))); @@ -386,7 +386,7 @@ mod tests { #[test] fn test_parse_length0() { - let buf = BytesMut::from(&[0b00000001u8, 0b00000000u8][..]); + let buf = BytesMut::from(&[0b0000_0001u8, 0b0000_0000u8][..]); let mut buf = PayloadHelper::new(once(Ok(buf.freeze()))); let frame = extract(Frame::parse(&mut buf, false, 1024)); @@ -397,11 +397,11 @@ mod tests { #[test] fn test_parse_length2() { - let buf = BytesMut::from(&[0b00000001u8, 126u8][..]); + let buf = BytesMut::from(&[0b0000_0001u8, 126u8][..]); let mut buf = PayloadHelper::new(once(Ok(buf.freeze()))); - assert!(is_none(Frame::parse(&mut buf, false, 1024))); + assert!(is_none(&Frame::parse(&mut buf, false, 1024))); - let mut buf = BytesMut::from(&[0b00000001u8, 126u8][..]); + let mut buf = BytesMut::from(&[0b0000_0001u8, 126u8][..]); buf.extend(&[0u8, 4u8][..]); buf.extend(b"1234"); let mut buf = PayloadHelper::new(once(Ok(buf.freeze()))); @@ -414,11 +414,11 @@ mod tests { #[test] fn test_parse_length4() { - let buf = BytesMut::from(&[0b00000001u8, 127u8][..]); + let buf = BytesMut::from(&[0b0000_0001u8, 127u8][..]); let mut buf = PayloadHelper::new(once(Ok(buf.freeze()))); - assert!(is_none(Frame::parse(&mut buf, false, 1024))); + assert!(is_none(&Frame::parse(&mut buf, false, 1024))); - let mut buf = BytesMut::from(&[0b00000001u8, 127u8][..]); + let mut buf = BytesMut::from(&[0b0000_0001u8, 127u8][..]); buf.extend(&[0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 4u8][..]); buf.extend(b"1234"); let mut buf = PayloadHelper::new(once(Ok(buf.freeze()))); @@ -431,7 +431,7 @@ mod tests { #[test] fn test_parse_frame_mask() { - let mut buf = BytesMut::from(&[0b00000001u8, 0b10000001u8][..]); + let mut buf = BytesMut::from(&[0b0000_0001u8, 0b1000_0001u8][..]); buf.extend(b"0001"); buf.extend(b"1"); let mut buf = PayloadHelper::new(once(Ok(buf.freeze()))); @@ -446,7 +446,7 @@ mod tests { #[test] fn test_parse_frame_no_mask() { - let mut buf = BytesMut::from(&[0b00000001u8, 0b00000001u8][..]); + let mut buf = BytesMut::from(&[0b0000_0001u8, 0b0000_0001u8][..]); buf.extend(&[1u8]); let mut buf = PayloadHelper::new(once(Ok(buf.freeze()))); @@ -460,7 +460,7 @@ mod tests { #[test] fn test_parse_frame_max_size() { - let mut buf = BytesMut::from(&[0b00000001u8, 0b00000010u8][..]); + let mut buf = BytesMut::from(&[0b0000_0001u8, 0b0000_0010u8][..]); buf.extend(&[1u8, 1u8]); let mut buf = PayloadHelper::new(once(Ok(buf.freeze())));