diff --git a/src/client/mod.rs b/src/client/mod.rs index 5a42064a..5d48fb60 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -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 }; diff --git a/src/client/request.rs b/src/client/request.rs index 1dba0f63..7c3060c3 100644 --- a/src/client/request.rs +++ b/src/client/request.rs @@ -80,8 +80,8 @@ impl Request { /// Create a new client request. pub fn new(method: Method, url: Url) -> ::Result> { - 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. diff --git a/src/header/common/authorization.rs b/src/header/common/authorization.rs index d8179405..7d2d0c94 100644 --- a/src/header/common/authorization.rs +++ b/src/header/common/authorization.rs @@ -60,13 +60,13 @@ pub struct Authorization(pub S); impl Deref for Authorization { type Target = S; - fn deref<'a>(&'a self) -> &'a S { + fn deref(&self) -> &S { &self.0 } } impl DerefMut for Authorization { - 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 Header for Authorization where ::Err: 'st return Err(::Error::Header); } let header = try!(from_utf8(unsafe { &raw.get_unchecked(0)[..] })); - return if let Some(scheme) = ::scheme() { + if let Some(scheme) = ::scheme() { if header.starts_with(scheme) && header.len() > scheme.len() + 1 { match header[scheme.len() + 1..].parse::().map(Authorization) { Ok(h) => Ok(h), diff --git a/src/header/common/content_disposition.rs b/src/header/common/content_disposition.rs index edb27fec..7816479f 100644 --- a/src/header/common/content_disposition.rs +++ b/src/header/common/content_disposition.rs @@ -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(()) diff --git a/src/header/common/content_range.rs b/src/header/common/content_range.rs index aeeed8ea..2d9a965b 100644 --- a/src/header/common/content_range.rs +++ b/src/header/common/content_range.rs @@ -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) diff --git a/src/header/common/if_range.rs b/src/header/common/if_range.rs index 874cd6fd..7399b3a4 100644 --- a/src/header/common/if_range.rs +++ b/src/header/common/if_range.rs @@ -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), } } } diff --git a/src/header/common/mod.rs b/src/header/common/mod.rs index 4fa9c6af..090f0237 100644 --- a/src/header/common/mod.rs +++ b/src/header/common/mod.rs @@ -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 { diff --git a/src/header/common/range.rs b/src/header/common/range.rs index 0651012a..8b09860b 100644 --- a/src/header/common/range.rs +++ b/src/header/common/range.rs @@ -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()) { diff --git a/src/header/internals/cell.rs b/src/header/internals/cell.rs index 65a45fdb..38365b73 100644 --- a/src/header/internals/cell.rs +++ b/src/header/internals/cell.rs @@ -32,7 +32,7 @@ impl OptCell { impl Deref for OptCell { type Target = Option; #[inline] - fn deref<'a>(&'a self) -> &'a Option { + fn deref(&self) -> &Option { unsafe { &*self.0.get() } } } diff --git a/src/header/mod.rs b/src/header/mod.rs index fa12d1de..b71dc717 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -193,7 +193,7 @@ impl Headers { } #[doc(hidden)] - pub fn from_raw<'a>(raw: &[httparse::Header<'a>]) -> ::Result { + pub fn from_raw(raw: &[httparse::Header]) -> ::Result { 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 } } diff --git a/src/header/shared/entity.rs b/src/header/shared/entity.rs index 30f5c6c0..0d51d5cf 100644 --- a/src/header/shared/entity.rs +++ b/src/header/shared/entity.rs @@ -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) } } } diff --git a/src/header/shared/quality_item.rs b/src/header/shared/quality_item.rs index 219b10cb..70089e4d 100644 --- a/src/header/shared/quality_item.rs +++ b/src/header/shared/quality_item.rs @@ -101,7 +101,7 @@ impl str::FromStr for QualityItem { match raw_item.parse::() { // 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), } } } diff --git a/src/http/h1.rs b/src/http/h1.rs index a6be4261..669a753e 100644 --- a/src/http/h1.rs +++ b/src/http/h1.rs @@ -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 HttpWriter { /// 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 HttpWriter { /// 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, diff --git a/src/http/h2.rs b/src/http/h2.rs index 94302898..cda4f0ca 100644 --- a/src/http/h2.rs +++ b/src/http/h2.rs @@ -302,7 +302,7 @@ fn prepare_headers(mut headers: Headers) -> Vec { /// A helper function that prepares the body for sending in an HTTP/2 request. #[inline] fn prepare_body(body: Vec) -> Option> { - if body.len() == 0 { + if body.is_empty() { None } else { Some(body) @@ -322,7 +322,7 @@ fn parse_headers(http2_headers: Vec) -> ::Result { } 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 }); }