style(all): Address suggestions made by rust-clippy
This commit is contained in:
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user