Skip to content

Commit

Permalink
Merge pull request #708 from frewsxcv/clippy
Browse files Browse the repository at this point in the history
Address suggestions made by rust-clippy
  • Loading branch information
seanmonstar committed Dec 28, 2015
2 parents 7d4db58 + 4c7f6f0 commit ac8a72a
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 38 deletions.
4 changes: 2 additions & 2 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
4 changes: 2 additions & 2 deletions src/client/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/header/common/authorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -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),
Expand Down
8 changes: 4 additions & 4 deletions src/header/common/content_disposition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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(())
Expand Down
10 changes: 5 additions & 5 deletions src/header/common/content_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)),
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/header/common/if_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/header/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/header/common/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion src/header/internals/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/header/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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[..]);
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -321,7 +321,7 @@ impl PartialEq for Headers {
_ => { return false; }
}
}
return true;
true
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/header/shared/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/header/shared/quality_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/http/h1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/http/h2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 });
}

Expand Down

0 comments on commit ac8a72a

Please sign in to comment.