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); | ||||
|         trace!("send {:?} {:?}", method, url); | ||||
|  | ||||
|         let can_have_body = match &method { | ||||
|             &Method::Get | &Method::Head => false, | ||||
|         let can_have_body = match method { | ||||
|             Method::Get | Method::Head => false, | ||||
|             _ => true | ||||
|         }; | ||||
|  | ||||
|   | ||||
| @@ -80,8 +80,8 @@ impl Request<Fresh> { | ||||
|  | ||||
|     /// Create a new client request. | ||||
|     pub fn new(method: Method, url: Url) -> ::Result<Request<Fresh>> { | ||||
|         let mut conn = DefaultConnector::default(); | ||||
|         Request::with_connector(method, url, &mut conn) | ||||
|         let conn = DefaultConnector::default(); | ||||
|         Request::with_connector(method, url, &conn) | ||||
|     } | ||||
|  | ||||
|     /// 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> { | ||||
|     type Target = S; | ||||
|  | ||||
|     fn deref<'a>(&'a self) -> &'a S { | ||||
|     fn deref(&self) -> &S { | ||||
|         &self.0 | ||||
|     } | ||||
| } | ||||
|  | ||||
| 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 | ||||
|     } | ||||
| } | ||||
| @@ -81,7 +81,7 @@ impl<S: Scheme + Any> Header for Authorization<S> where <S as FromStr>::Err: 'st | ||||
|             return Err(::Error::Header); | ||||
|         } | ||||
|         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 { | ||||
|                 match header[scheme.len() + 1..].parse::<S>().map(Authorization) { | ||||
|                     Ok(h) => Ok(h), | ||||
|   | ||||
| @@ -160,9 +160,9 @@ impl fmt::Display for ContentDisposition { | ||||
|             DispositionType::Attachment => try!(write!(f, "attachment")), | ||||
|             DispositionType::Ext(ref s) => try!(write!(f, "{}", s)), | ||||
|         } | ||||
|         for param in self.parameters.iter() { | ||||
|             match param { | ||||
|                 &DispositionParam::Filename(ref charset, ref opt_lang, ref bytes) => { | ||||
|         for param in &self.parameters { | ||||
|             match *param { | ||||
|                 DispositionParam::Filename(ref charset, ref opt_lang, ref bytes) => { | ||||
|                     let mut use_simple_format: bool = false; | ||||
|                     if opt_lang.is_none() { | ||||
|                         if let Charset::Ext(ref ext) = *charset { | ||||
| @@ -188,7 +188,7 @@ impl fmt::Display for ContentDisposition { | ||||
|                                 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(()) | ||||
|   | ||||
| @@ -31,8 +31,8 @@ header! { | ||||
|         test_header!(test_unregistered, | ||||
|             vec![b"seconds 1-2"], | ||||
|             Some(ContentRange(ContentRangeSpec::Unregistered { | ||||
|                 unit: "seconds".to_string(), | ||||
|                 resp: "1-2".to_string() | ||||
|                 unit: "seconds".to_owned(), | ||||
|                 resp: "1-2".to_owned() | ||||
|             }))); | ||||
|  | ||||
|         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); | ||||
|     match (iter.next(), iter.next()) { | ||||
|         (Some(a), Some(b)) => Some((a, b)), | ||||
| @@ -149,8 +149,8 @@ impl FromStr for ContentRangeSpec { | ||||
|             } | ||||
|             Some((unit, resp)) => { | ||||
|                 ContentRangeSpec::Unregistered { | ||||
|                     unit: unit.to_string(), | ||||
|                     resp: resp.to_string() | ||||
|                     unit: unit.to_owned(), | ||||
|                     resp: resp.to_owned() | ||||
|                 } | ||||
|             } | ||||
|             _ => return Err(::Error::Header) | ||||
|   | ||||
| @@ -72,9 +72,9 @@ impl Header for IfRange { | ||||
|  | ||||
| impl HeaderFormat for IfRange { | ||||
|     fn fmt_header(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { | ||||
|         match self { | ||||
|             &IfRange::EntityTag(ref x) => Display::fmt(x, f), | ||||
|             &IfRange::Date(ref x) => Display::fmt(x, f), | ||||
|         match *self { | ||||
|             IfRange::EntityTag(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 { | ||||
|             type Target = $to; | ||||
|  | ||||
|             fn deref<'a>(&'a self) -> &'a $to { | ||||
|             fn deref(&self) -> &$to { | ||||
|                 &self.0 | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         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 | ||||
|             } | ||||
|         } | ||||
| @@ -297,7 +297,7 @@ macro_rules! header { | ||||
|                         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 { | ||||
|   | ||||
| @@ -157,10 +157,10 @@ impl FromStr for ByteRangeSpec { | ||||
|  | ||||
|         match (parts.next(), parts.next()) { | ||||
|             (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("")) => { | ||||
|                 start.parse().or(Err(::Error::Header)).map(|start| ByteRangeSpec::AllFrom(start)) | ||||
|                 start.parse().or(Err(::Error::Header)).map(ByteRangeSpec::AllFrom) | ||||
|             }, | ||||
|             (Some(start), Some(end)) => { | ||||
|                 match (start.parse(), end.parse()) { | ||||
|   | ||||
| @@ -32,7 +32,7 @@ impl<T> OptCell<T> { | ||||
| impl<T> Deref for OptCell<T> { | ||||
|     type Target = Option<T>; | ||||
|     #[inline] | ||||
|     fn deref<'a>(&'a self) -> &'a Option<T> { | ||||
|     fn deref(&self) -> &Option<T> { | ||||
|         unsafe { &*self.0.get() } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -193,7 +193,7 @@ impl Headers { | ||||
|     } | ||||
|  | ||||
|     #[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(); | ||||
|         for header in raw { | ||||
|             trace!("raw header: {:?}={:?}", header.name, &header.value[..]); | ||||
| @@ -292,7 +292,7 @@ impl Headers { | ||||
|     } | ||||
|  | ||||
|     /// Returns an iterator over the header fields. | ||||
|     pub fn iter<'a>(&'a self) -> HeadersItems<'a> { | ||||
|     pub fn iter(&self) -> HeadersItems { | ||||
|         HeadersItems { | ||||
|             inner: self.data.iter() | ||||
|         } | ||||
| @@ -321,7 +321,7 @@ impl PartialEq for Headers { | ||||
|                 _ => { return false; } | ||||
|             } | ||||
|         } | ||||
|         return true; | ||||
|         true | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -109,9 +109,10 @@ impl EntityTag { | ||||
|  | ||||
| impl Display for EntityTag { | ||||
|     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||||
|         match self.weak { | ||||
|             true => write!(f, "W/\"{}\"", self.tag), | ||||
|             false => write!(f, "\"{}\"", self.tag), | ||||
|         if self.weak { | ||||
|             write!(f, "W/\"{}\"", 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>() { | ||||
|             // we already checked above that the quality is within range | ||||
|             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 { | ||||
|                     &Method::Get | &Method::Head => { | ||||
|                 match head.method { | ||||
|                     Method::Get | Method::Head => { | ||||
|                         let writer = match write_headers(stream, &head) { | ||||
|                             Ok(w) => w, | ||||
|                             Err(e) => { | ||||
| @@ -734,7 +734,7 @@ impl<W: Write> HttpWriter<W> { | ||||
|  | ||||
|     /// Access the inner Writer. | ||||
|     #[inline] | ||||
|     pub fn get_ref<'a>(&'a self) -> &'a W { | ||||
|     pub fn get_ref(&self) -> &W { | ||||
|         match *self { | ||||
|             ThroughWriter(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 | ||||
|     /// the state. | ||||
|     #[inline] | ||||
|     pub fn get_mut<'a>(&'a mut self) -> &'a mut W { | ||||
|     pub fn get_mut(&mut self) -> &mut W { | ||||
|         match *self { | ||||
|             ThroughWriter(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. | ||||
| #[inline] | ||||
| fn prepare_body(body: Vec<u8>) -> Option<Vec<u8>> { | ||||
|     if body.len() == 0 { | ||||
|     if body.is_empty() { | ||||
|         None | ||||
|     } else { | ||||
|         Some(body) | ||||
| @@ -322,7 +322,7 @@ fn parse_headers(http2_headers: Vec<Http2Header>) -> ::Result<Headers> { | ||||
|     } | ||||
|  | ||||
|     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 }); | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user