From f27dd19093014de6fed68cd3025e77f21f52a9e8 Mon Sep 17 00:00:00 2001
From: Yuki Okushi <huyuumi.dev@gmail.com>
Date: Thu, 27 Feb 2020 11:20:30 +0900
Subject: [PATCH] Fix Clippy warnings

---
 actix-http/src/error.rs                             |  1 -
 actix-http/src/h1/decoder.rs                        |  1 -
 actix-http/src/header/common/content_disposition.rs | 10 +++++-----
 actix-http/src/helpers.rs                           |  4 ++--
 actix-http/src/response.rs                          |  1 -
 actix-http/src/ws/frame.rs                          |  1 -
 actix-http/src/ws/proto.rs                          |  2 --
 7 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/actix-http/src/error.rs b/actix-http/src/error.rs
index b13481551..0850e18ff 100644
--- a/actix-http/src/error.rs
+++ b/actix-http/src/error.rs
@@ -14,7 +14,6 @@ use derive_more::{Display, From};
 pub use futures_channel::oneshot::Canceled;
 use http::uri::InvalidUri;
 use http::{header, Error as HttpError, StatusCode};
-use httparse;
 use serde::de::value::Error as DeError;
 use serde_json::error::Error as JsonError;
 use serde_urlencoded::ser::Error as FormError;
diff --git a/actix-http/src/h1/decoder.rs b/actix-http/src/h1/decoder.rs
index e113fd52d..d3ccd8e5a 100644
--- a/actix-http/src/h1/decoder.rs
+++ b/actix-http/src/h1/decoder.rs
@@ -8,7 +8,6 @@ use actix_codec::Decoder;
 use bytes::{Buf, Bytes, BytesMut};
 use http::header::{HeaderName, HeaderValue};
 use http::{header, Method, StatusCode, Uri, Version};
-use httparse;
 use log::{debug, error, trace};
 
 use crate::error::ParseError;
diff --git a/actix-http/src/header/common/content_disposition.rs b/actix-http/src/header/common/content_disposition.rs
index d0d5af765..aa2e00ec0 100644
--- a/actix-http/src/header/common/content_disposition.rs
+++ b/actix-http/src/header/common/content_disposition.rs
@@ -423,7 +423,7 @@ impl ContentDisposition {
 
     /// Return the value of *name* if exists.
     pub fn get_name(&self) -> Option<&str> {
-        self.parameters.iter().filter_map(|p| p.as_name()).nth(0)
+        self.parameters.iter().filter_map(|p| p.as_name()).next()
     }
 
     /// Return the value of *filename* if exists.
@@ -431,7 +431,7 @@ impl ContentDisposition {
         self.parameters
             .iter()
             .filter_map(|p| p.as_filename())
-            .nth(0)
+            .next()
     }
 
     /// Return the value of *filename\** if exists.
@@ -439,7 +439,7 @@ impl ContentDisposition {
         self.parameters
             .iter()
             .filter_map(|p| p.as_filename_ext())
-            .nth(0)
+            .next()
     }
 
     /// Return the value of the parameter which the `name` matches.
@@ -448,7 +448,7 @@ impl ContentDisposition {
         self.parameters
             .iter()
             .filter_map(|p| p.as_unknown(name))
-            .nth(0)
+            .next()
     }
 
     /// Return the value of the extended parameter which the `name` matches.
@@ -457,7 +457,7 @@ impl ContentDisposition {
         self.parameters
             .iter()
             .filter_map(|p| p.as_unknown_ext(name))
-            .nth(0)
+            .next()
     }
 }
 
diff --git a/actix-http/src/helpers.rs b/actix-http/src/helpers.rs
index 6599f6a32..86f8250b6 100644
--- a/actix-http/src/helpers.rs
+++ b/actix-http/src/helpers.rs
@@ -117,7 +117,7 @@ pub fn write_content_length(n: usize, bytes: &mut BytesMut) {
     } else if n < 1_000_000 {
         let n = n as u32;
 
-        let d100000 = (n / 100000) as u8;
+        let d100000 = (n / 100_000) as u8;
         let d10000 = ((n / 10000) % 10) as u8;
         let d1000 = ((n / 1000) % 10) as u8;
         let d100 = ((n / 100) % 10) as u8;
@@ -149,7 +149,7 @@ pub(crate) fn write_usize(n: usize, bytes: &mut BytesMut) {
         let lsd = (n % 10) as u8;
 
         // remove the lsd from n
-        n = n / 10;
+        n /= 10;
 
         buf.put_u8(DIGITS_START + lsd);
     }
diff --git a/actix-http/src/response.rs b/actix-http/src/response.rs
index 655d565ad..7a9b82df2 100644
--- a/actix-http/src/response.rs
+++ b/actix-http/src/response.rs
@@ -9,7 +9,6 @@ use std::{fmt, str};
 use bytes::{Bytes, BytesMut};
 use futures_core::Stream;
 use serde::Serialize;
-use serde_json;
 
 use crate::body::{Body, BodyStream, MessageBody, ResponseBody};
 use crate::cookie::{Cookie, CookieJar};
diff --git a/actix-http/src/ws/frame.rs b/actix-http/src/ws/frame.rs
index 3c70eb2bd..8f7004f18 100644
--- a/actix-http/src/ws/frame.rs
+++ b/actix-http/src/ws/frame.rs
@@ -2,7 +2,6 @@ use std::convert::TryFrom;
 
 use bytes::{Buf, BufMut, BytesMut};
 use log::debug;
-use rand;
 
 use crate::ws::mask::apply_mask;
 use crate::ws::proto::{CloseCode, CloseReason, OpCode};
diff --git a/actix-http/src/ws/proto.rs b/actix-http/src/ws/proto.rs
index 60af6f08b..7b55cbf1a 100644
--- a/actix-http/src/ws/proto.rs
+++ b/actix-http/src/ws/proto.rs
@@ -1,5 +1,3 @@
-use base64;
-use sha1;
 use std::convert::{From, Into};
 use std::fmt;