refactor(multiple): Clippy run

This commit is contained in:
leonardo.yvens
2016-06-04 11:21:53 -03:00
parent 0c847f7898
commit d4a095d75c
16 changed files with 50 additions and 71 deletions

View File

@@ -95,7 +95,7 @@ impl Display for RangeUnit {
match *self {
RangeUnit::Bytes => f.write_str("bytes"),
RangeUnit::None => f.write_str("none"),
RangeUnit::Unregistered(ref x) => f.write_str(&x),
RangeUnit::Unregistered(ref x) => f.write_str(x),
}
}
}

View File

@@ -182,7 +182,7 @@ impl Display for ContentRangeSpec {
ContentRangeSpec::Unregistered { ref unit, ref resp } => {
try!(f.write_str(&unit));
try!(f.write_str(" "));
f.write_str(&resp)
f.write_str(resp)
}
}
}

View File

@@ -69,14 +69,10 @@ impl Header for Host {
}
};
let port = match idx {
Some(idx) => s[idx + 1..].parse().ok(),
None => None
};
let port = idx.and_then(|idx| s[idx + 1..].parse().ok());
match idx {
Some(idx) => s.truncate(idx),
None => ()
if let Some(idx) = idx {
s.truncate(idx)
}
Ok(Host {

View File

@@ -106,7 +106,7 @@ impl fmt::Display for Preference {
Extension(ref name, ref value, ref params) => {
try!(write!(f, "{}", name));
if value != "" { try!(write!(f, "={}", value)); }
if params.len() > 0 {
if !params.is_empty() {
for &(ref name, ref value) in params {
try!(write!(f, "; {}", name));
if value != "" { try!(write!(f, "={}", value)); }
@@ -138,12 +138,12 @@ impl FromStr for Preference {
Some(param) => {
let rest: Vec<(String, String)> = params.map(|(l, r)| (l.to_owned(), r.to_owned())).collect();
match param {
("respond-async", "") => if rest.len() == 0 { Ok(RespondAsync) } else { Err(None) },
("return", "representation") => if rest.len() == 0 { Ok(ReturnRepresentation) } else { Err(None) },
("return", "minimal") => if rest.len() == 0 { Ok(ReturnMinimal) } else { Err(None) },
("handling", "strict") => if rest.len() == 0 { Ok(HandlingStrict) } else { Err(None) },
("handling", "leniant") => if rest.len() == 0 { Ok(HandlingLeniant) } else { Err(None) },
("wait", secs) => if rest.len() == 0 { secs.parse().map(Wait).map_err(Some) } else { Err(None) },
("respond-async", "") => if rest.is_empty() { Ok(RespondAsync) } else { Err(None) },
("return", "representation") => if rest.is_empty() { Ok(ReturnRepresentation) } else { Err(None) },
("return", "minimal") => if rest.is_empty() { Ok(ReturnMinimal) } else { Err(None) },
("handling", "strict") => if rest.is_empty() { Ok(HandlingStrict) } else { Err(None) },
("handling", "leniant") => if rest.is_empty() { Ok(HandlingLeniant) } else { Err(None) },
("wait", secs) => if rest.is_empty() { secs.parse().map(Wait).map_err(Some) } else { Err(None) },
(left, right) => Ok(Extension(left.to_owned(), right.to_owned(), rest))
}
},

View File

@@ -71,7 +71,7 @@ impl Header for PreferenceApplied {
value.to_owned(),
vec![]
),
preference @ _ => preference.clone()
preference => preference.clone()
}).collect();
fmt_comma_delimited(f, &preferences)
}

View File

@@ -126,7 +126,7 @@ impl FromStr for Range {
type Err = ::Error;
fn from_str(s: &str) -> ::Result<Range> {
let mut iter = s.splitn(2, "=");
let mut iter = s.splitn(2, '=');
match (iter.next(), iter.next()) {
(Some("bytes"), Some(ranges)) => {
@@ -153,7 +153,7 @@ impl FromStr for ByteRangeSpec {
type Err = ::Error;
fn from_str(s: &str) -> ::Result<ByteRangeSpec> {
let mut parts = s.splitn(2, "-");
let mut parts = s.splitn(2, '-');
match (parts.next(), parts.next()) {
(Some(""), Some(end)) => {

View File

@@ -143,12 +143,12 @@ impl<T: Header + Clone> HeaderClone for T {
impl Header + Send + Sync {
#[inline]
unsafe fn downcast_ref_unchecked<T: 'static>(&self) -> &T {
mem::transmute(traitobject::data(self))
&*(traitobject::data(self) as *const T)
}
#[inline]
unsafe fn downcast_mut_unchecked<T: 'static>(&mut self) -> &mut T {
mem::transmute(traitobject::data_mut(self))
&mut *(traitobject::data_mut(self) as *mut T)
}
}
@@ -497,7 +497,7 @@ impl<'a> fmt::Display for &'a (Header + Send + Sync) {
}
}
/// A wrapper around any Header with a Display impl that calls fmt_header.
/// A wrapper around any Header with a Display impl that calls `fmt_header`.
///
/// This can be used like so: `format!("{}", HeaderFormatter(&header))` to
/// get the representation of a Header which will be written to an

View File

@@ -12,7 +12,7 @@ use header::shared::Charset;
pub fn from_one_raw_str<T: str::FromStr>(raw: &[Vec<u8>]) -> ::Result<T> {
if raw.len() != 1 || unsafe { raw.get_unchecked(0) } == b"" { return Err(::Error::Header) }
// we JUST checked that raw.len() == 1, so raw[0] WILL exist.
from_raw_str(& unsafe { raw.get_unchecked(0) })
from_raw_str( unsafe { raw.get_unchecked(0) })
}
/// Reads a raw string into a value.

View File

@@ -91,7 +91,7 @@ impl Charset {
Gb2312 => "GB2312",
Big5 => "5",
Koi8_R => "KOI8-R",
Ext(ref s) => &s
Ext(ref s) => s
}
}
}

View File

@@ -4,10 +4,10 @@ use std::fmt::{self, Display};
// check that each char in the slice is either:
// 1. %x21, or
// 2. in the range %x23 to %x7E, or
// 3. in the range %x80 to %xFF
// 3. above %x80
fn check_slice_validity(slice: &str) -> bool {
slice.bytes().all(|c|
c == b'\x21' || (c >= b'\x23' && c <= b'\x7e') | (c >= b'\x80' && c <= b'\xff'))
c == b'\x21' || (c >= b'\x23' && c <= b'\x7e') | (c >= b'\x80'))
}
/// An entity tag, defined in [RFC7232](https://tools.ietf.org/html/rfc7232#section-2.3)