style(all): Address suggestions made by rust-clippy
This commit is contained in:
		| @@ -239,8 +239,8 @@ impl<'a> RequestBuilder<'a> { | |||||||
|         let mut url = try!(url); |         let mut url = try!(url); | ||||||
|         trace!("send {:?} {:?}", method, url); |         trace!("send {:?} {:?}", method, url); | ||||||
|  |  | ||||||
|         let can_have_body = match &method { |         let can_have_body = match method { | ||||||
|             &Method::Get | &Method::Head => false, |             Method::Get | Method::Head => false, | ||||||
|             _ => true |             _ => true | ||||||
|         }; |         }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -80,8 +80,8 @@ impl Request<Fresh> { | |||||||
|  |  | ||||||
|     /// Create a new client request. |     /// Create a new client request. | ||||||
|     pub fn new(method: Method, url: Url) -> ::Result<Request<Fresh>> { |     pub fn new(method: Method, url: Url) -> ::Result<Request<Fresh>> { | ||||||
|         let mut conn = DefaultConnector::default(); |         let conn = DefaultConnector::default(); | ||||||
|         Request::with_connector(method, url, &mut conn) |         Request::with_connector(method, url, &conn) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// Create a new client request with a specific underlying NetworkStream. |     /// Create a new client request with a specific underlying NetworkStream. | ||||||
|   | |||||||
| @@ -60,13 +60,13 @@ pub struct Authorization<S: Scheme>(pub S); | |||||||
| impl<S: Scheme> Deref for Authorization<S> { | impl<S: Scheme> Deref for Authorization<S> { | ||||||
|     type Target = S; |     type Target = S; | ||||||
|  |  | ||||||
|     fn deref<'a>(&'a self) -> &'a S { |     fn deref(&self) -> &S { | ||||||
|         &self.0 |         &self.0 | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| impl<S: Scheme> DerefMut for Authorization<S> { | impl<S: Scheme> DerefMut for Authorization<S> { | ||||||
|     fn deref_mut<'a>(&'a mut self) -> &'a mut S { |     fn deref_mut(&mut self) -> &mut S { | ||||||
|         &mut self.0 |         &mut self.0 | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -81,7 +81,7 @@ impl<S: Scheme + Any> Header for Authorization<S> where <S as FromStr>::Err: 'st | |||||||
|             return Err(::Error::Header); |             return Err(::Error::Header); | ||||||
|         } |         } | ||||||
|         let header = try!(from_utf8(unsafe { &raw.get_unchecked(0)[..] })); |         let header = try!(from_utf8(unsafe { &raw.get_unchecked(0)[..] })); | ||||||
|         return if let Some(scheme) = <S as Scheme>::scheme() { |         if let Some(scheme) = <S as Scheme>::scheme() { | ||||||
|             if header.starts_with(scheme) && header.len() > scheme.len() + 1 { |             if header.starts_with(scheme) && header.len() > scheme.len() + 1 { | ||||||
|                 match header[scheme.len() + 1..].parse::<S>().map(Authorization) { |                 match header[scheme.len() + 1..].parse::<S>().map(Authorization) { | ||||||
|                     Ok(h) => Ok(h), |                     Ok(h) => Ok(h), | ||||||
|   | |||||||
| @@ -160,9 +160,9 @@ impl fmt::Display for ContentDisposition { | |||||||
|             DispositionType::Attachment => try!(write!(f, "attachment")), |             DispositionType::Attachment => try!(write!(f, "attachment")), | ||||||
|             DispositionType::Ext(ref s) => try!(write!(f, "{}", s)), |             DispositionType::Ext(ref s) => try!(write!(f, "{}", s)), | ||||||
|         } |         } | ||||||
|         for param in self.parameters.iter() { |         for param in &self.parameters { | ||||||
|             match param { |             match *param { | ||||||
|                 &DispositionParam::Filename(ref charset, ref opt_lang, ref bytes) => { |                 DispositionParam::Filename(ref charset, ref opt_lang, ref bytes) => { | ||||||
|                     let mut use_simple_format: bool = false; |                     let mut use_simple_format: bool = false; | ||||||
|                     if opt_lang.is_none() { |                     if opt_lang.is_none() { | ||||||
|                         if let Charset::Ext(ref ext) = *charset { |                         if let Charset::Ext(ref ext) = *charset { | ||||||
| @@ -188,7 +188,7 @@ impl fmt::Display for ContentDisposition { | |||||||
|                                 bytes, percent_encoding::HTTP_VALUE_ENCODE_SET))) |                                 bytes, percent_encoding::HTTP_VALUE_ENCODE_SET))) | ||||||
|                     } |                     } | ||||||
|                 }, |                 }, | ||||||
|                 &DispositionParam::Ext(ref k, ref v) => try!(write!(f, "; {}=\"{}\"", k, v)), |                 DispositionParam::Ext(ref k, ref v) => try!(write!(f, "; {}=\"{}\"", k, v)), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         Ok(()) |         Ok(()) | ||||||
|   | |||||||
| @@ -31,8 +31,8 @@ header! { | |||||||
|         test_header!(test_unregistered, |         test_header!(test_unregistered, | ||||||
|             vec![b"seconds 1-2"], |             vec![b"seconds 1-2"], | ||||||
|             Some(ContentRange(ContentRangeSpec::Unregistered { |             Some(ContentRange(ContentRangeSpec::Unregistered { | ||||||
|                 unit: "seconds".to_string(), |                 unit: "seconds".to_owned(), | ||||||
|                 resp: "1-2".to_string() |                 resp: "1-2".to_owned() | ||||||
|             }))); |             }))); | ||||||
|  |  | ||||||
|         test_header!(test_no_len, |         test_header!(test_no_len, | ||||||
| @@ -108,7 +108,7 @@ pub enum ContentRangeSpec { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| fn split_in_two<'a>(s: &'a str, separator: char) -> Option<(&'a str, &'a str)> { | fn split_in_two(s: &str, separator: char) -> Option<(&str, &str)> { | ||||||
|     let mut iter = s.splitn(2, separator); |     let mut iter = s.splitn(2, separator); | ||||||
|     match (iter.next(), iter.next()) { |     match (iter.next(), iter.next()) { | ||||||
|         (Some(a), Some(b)) => Some((a, b)), |         (Some(a), Some(b)) => Some((a, b)), | ||||||
| @@ -149,8 +149,8 @@ impl FromStr for ContentRangeSpec { | |||||||
|             } |             } | ||||||
|             Some((unit, resp)) => { |             Some((unit, resp)) => { | ||||||
|                 ContentRangeSpec::Unregistered { |                 ContentRangeSpec::Unregistered { | ||||||
|                     unit: unit.to_string(), |                     unit: unit.to_owned(), | ||||||
|                     resp: resp.to_string() |                     resp: resp.to_owned() | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             _ => return Err(::Error::Header) |             _ => return Err(::Error::Header) | ||||||
|   | |||||||
| @@ -72,9 +72,9 @@ impl Header for IfRange { | |||||||
|  |  | ||||||
| impl HeaderFormat for IfRange { | impl HeaderFormat for IfRange { | ||||||
|     fn fmt_header(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { |     fn fmt_header(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { | ||||||
|         match self { |         match *self { | ||||||
|             &IfRange::EntityTag(ref x) => Display::fmt(x, f), |             IfRange::EntityTag(ref x) => Display::fmt(x, f), | ||||||
|             &IfRange::Date(ref x) => Display::fmt(x, f), |             IfRange::Date(ref x) => Display::fmt(x, f), | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -91,13 +91,13 @@ macro_rules! __hyper__deref { | |||||||
|         impl ::std::ops::Deref for $from { |         impl ::std::ops::Deref for $from { | ||||||
|             type Target = $to; |             type Target = $to; | ||||||
|  |  | ||||||
|             fn deref<'a>(&'a self) -> &'a $to { |             fn deref(&self) -> &$to { | ||||||
|                 &self.0 |                 &self.0 | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         impl ::std::ops::DerefMut for $from { |         impl ::std::ops::DerefMut for $from { | ||||||
|             fn deref_mut<'a>(&'a mut self) -> &'a mut $to { |             fn deref_mut(&mut self) -> &mut $to { | ||||||
|                 &mut self.0 |                 &mut self.0 | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| @@ -297,7 +297,7 @@ macro_rules! header { | |||||||
|                         return Ok($id::Any) |                         return Ok($id::Any) | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|                 $crate::header::parsing::from_comma_delimited(raw).map(|vec| $id::Items(vec)) |                 $crate::header::parsing::from_comma_delimited(raw).map($id::Items) | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         impl $crate::header::HeaderFormat for $id { |         impl $crate::header::HeaderFormat for $id { | ||||||
|   | |||||||
| @@ -157,10 +157,10 @@ impl FromStr for ByteRangeSpec { | |||||||
|  |  | ||||||
|         match (parts.next(), parts.next()) { |         match (parts.next(), parts.next()) { | ||||||
|             (Some(""), Some(end)) => { |             (Some(""), Some(end)) => { | ||||||
|                 end.parse().or(Err(::Error::Header)).map(|end| ByteRangeSpec::Last(end)) |                 end.parse().or(Err(::Error::Header)).map(ByteRangeSpec::Last) | ||||||
|             }, |             }, | ||||||
|             (Some(start), Some("")) => { |             (Some(start), Some("")) => { | ||||||
|                 start.parse().or(Err(::Error::Header)).map(|start| ByteRangeSpec::AllFrom(start)) |                 start.parse().or(Err(::Error::Header)).map(ByteRangeSpec::AllFrom) | ||||||
|             }, |             }, | ||||||
|             (Some(start), Some(end)) => { |             (Some(start), Some(end)) => { | ||||||
|                 match (start.parse(), end.parse()) { |                 match (start.parse(), end.parse()) { | ||||||
|   | |||||||
| @@ -32,7 +32,7 @@ impl<T> OptCell<T> { | |||||||
| impl<T> Deref for OptCell<T> { | impl<T> Deref for OptCell<T> { | ||||||
|     type Target = Option<T>; |     type Target = Option<T>; | ||||||
|     #[inline] |     #[inline] | ||||||
|     fn deref<'a>(&'a self) -> &'a Option<T> { |     fn deref(&self) -> &Option<T> { | ||||||
|         unsafe { &*self.0.get() } |         unsafe { &*self.0.get() } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -193,7 +193,7 @@ impl Headers { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     #[doc(hidden)] |     #[doc(hidden)] | ||||||
|     pub fn from_raw<'a>(raw: &[httparse::Header<'a>]) -> ::Result<Headers> { |     pub fn from_raw(raw: &[httparse::Header]) -> ::Result<Headers> { | ||||||
|         let mut headers = Headers::new(); |         let mut headers = Headers::new(); | ||||||
|         for header in raw { |         for header in raw { | ||||||
|             trace!("raw header: {:?}={:?}", header.name, &header.value[..]); |             trace!("raw header: {:?}={:?}", header.name, &header.value[..]); | ||||||
| @@ -292,7 +292,7 @@ impl Headers { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// Returns an iterator over the header fields. |     /// Returns an iterator over the header fields. | ||||||
|     pub fn iter<'a>(&'a self) -> HeadersItems<'a> { |     pub fn iter(&self) -> HeadersItems { | ||||||
|         HeadersItems { |         HeadersItems { | ||||||
|             inner: self.data.iter() |             inner: self.data.iter() | ||||||
|         } |         } | ||||||
| @@ -321,7 +321,7 @@ impl PartialEq for Headers { | |||||||
|                 _ => { return false; } |                 _ => { return false; } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         return true; |         true | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -109,9 +109,10 @@ impl EntityTag { | |||||||
|  |  | ||||||
| impl Display for EntityTag { | impl Display for EntityTag { | ||||||
|     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||||||
|         match self.weak { |         if self.weak { | ||||||
|             true => write!(f, "W/\"{}\"", self.tag), |             write!(f, "W/\"{}\"", self.tag) | ||||||
|             false => write!(f, "\"{}\"", self.tag), |         } else { | ||||||
|  |             write!(f, "\"{}\"", self.tag) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -101,7 +101,7 @@ impl<T: str::FromStr> str::FromStr for QualityItem<T> { | |||||||
|         match raw_item.parse::<T>() { |         match raw_item.parse::<T>() { | ||||||
|             // we already checked above that the quality is within range |             // we already checked above that the quality is within range | ||||||
|             Ok(item) => Ok(QualityItem::new(item, from_f32(quality))), |             Ok(item) => Ok(QualityItem::new(item, from_f32(quality))), | ||||||
|             Err(_) => return Err(::Error::Header), |             Err(_) => Err(::Error::Header), | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -171,8 +171,8 @@ impl HttpMessage for Http11Message { | |||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 }; |                 }; | ||||||
|                 match &head.method { |                 match head.method { | ||||||
|                     &Method::Get | &Method::Head => { |                     Method::Get | Method::Head => { | ||||||
|                         let writer = match write_headers(stream, &head) { |                         let writer = match write_headers(stream, &head) { | ||||||
|                             Ok(w) => w, |                             Ok(w) => w, | ||||||
|                             Err(e) => { |                             Err(e) => { | ||||||
| @@ -734,7 +734,7 @@ impl<W: Write> HttpWriter<W> { | |||||||
|  |  | ||||||
|     /// Access the inner Writer. |     /// Access the inner Writer. | ||||||
|     #[inline] |     #[inline] | ||||||
|     pub fn get_ref<'a>(&'a self) -> &'a W { |     pub fn get_ref(&self) -> &W { | ||||||
|         match *self { |         match *self { | ||||||
|             ThroughWriter(ref w) => w, |             ThroughWriter(ref w) => w, | ||||||
|             ChunkedWriter(ref w) => w, |             ChunkedWriter(ref w) => w, | ||||||
| @@ -748,7 +748,7 @@ impl<W: Write> HttpWriter<W> { | |||||||
|     /// Warning: You should not write to this directly, as you can corrupt |     /// Warning: You should not write to this directly, as you can corrupt | ||||||
|     /// the state. |     /// the state. | ||||||
|     #[inline] |     #[inline] | ||||||
|     pub fn get_mut<'a>(&'a mut self) -> &'a mut W { |     pub fn get_mut(&mut self) -> &mut W { | ||||||
|         match *self { |         match *self { | ||||||
|             ThroughWriter(ref mut w) => w, |             ThroughWriter(ref mut w) => w, | ||||||
|             ChunkedWriter(ref mut w) => w, |             ChunkedWriter(ref mut w) => w, | ||||||
|   | |||||||
| @@ -302,7 +302,7 @@ fn prepare_headers(mut headers: Headers) -> Vec<Http2Header> { | |||||||
| /// A helper function that prepares the body for sending in an HTTP/2 request. | /// A helper function that prepares the body for sending in an HTTP/2 request. | ||||||
| #[inline] | #[inline] | ||||||
| fn prepare_body(body: Vec<u8>) -> Option<Vec<u8>> { | fn prepare_body(body: Vec<u8>) -> Option<Vec<u8>> { | ||||||
|     if body.len() == 0 { |     if body.is_empty() { | ||||||
|         None |         None | ||||||
|     } else { |     } else { | ||||||
|         Some(body) |         Some(body) | ||||||
| @@ -322,7 +322,7 @@ fn parse_headers(http2_headers: Vec<Http2Header>) -> ::Result<Headers> { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     let mut raw_headers = Vec::new(); |     let mut raw_headers = Vec::new(); | ||||||
|     for &(ref name, ref value) in headers.iter() { |     for &(ref name, ref value) in &headers { | ||||||
|         raw_headers.push(httparse::Header { name: &name, value: &value }); |         raw_headers.push(httparse::Header { name: &name, value: &value }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user