From e25483a0d58ebf6b688fb195d94471223a082cc1 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 6 Mar 2019 21:12:35 -0800 Subject: [PATCH] fix warnings --- src/error.rs | 12 +----------- src/header/common/content_disposition.rs | 4 ++-- src/header/shared/quality_item.rs | 2 +- src/request.rs | 2 +- src/test.rs | 2 -- src/ws/client/mod.rs | 14 -------------- 6 files changed, 5 insertions(+), 31 deletions(-) diff --git a/src/error.rs b/src/error.rs index 4762f27ff..a3037b985 100644 --- a/src/error.rs +++ b/src/error.rs @@ -970,23 +970,13 @@ where #[cfg(feature = "fail")] mod failure_integration { use super::*; - use failure::{self, Fail}; /// Compatibility for `failure::Error` - impl ResponseError for failure::Compat - where - T: fmt::Display + fmt::Debug + Sync + Send + 'static, - { + impl ResponseError for failure::Error { fn error_response(&self) -> Response { Response::new(StatusCode::INTERNAL_SERVER_ERROR) } } - - impl From for Error { - fn from(err: failure::Error) -> Error { - err.compat().into() - } - } } #[cfg(test)] diff --git a/src/header/common/content_disposition.rs b/src/header/common/content_disposition.rs index e04f9c89f..700400dad 100644 --- a/src/header/common/content_disposition.rs +++ b/src/header/common/content_disposition.rs @@ -27,7 +27,7 @@ fn split_once(haystack: &str, needle: char) -> (&str, &str) { /// first part and the left of the last part. fn split_once_and_trim(haystack: &str, needle: char) -> (&str, &str) { let (first, last) = split_once(haystack, needle); - (first.trim_right(), last.trim_left()) + (first.trim_end(), last.trim_start()) } /// The implied disposition of the content of the HTTP body. @@ -324,7 +324,7 @@ impl ContentDisposition { } } left = &left[end.ok_or(crate::error::ParseError::Header)? + 1..]; - left = split_once(left, ';').1.trim_left(); + left = split_once(left, ';').1.trim_start(); // In fact, it should not be Err if the above code is correct. String::from_utf8(quoted_string) .map_err(|_| crate::error::ParseError::Header)? diff --git a/src/header/shared/quality_item.rs b/src/header/shared/quality_item.rs index 07c206581..fc3930c5e 100644 --- a/src/header/shared/quality_item.rs +++ b/src/header/shared/quality_item.rs @@ -58,7 +58,7 @@ impl fmt::Display for QualityItem { match self.quality.0 { 1000 => Ok(()), 0 => f.write_str("; q=0"), - x => write!(f, "; q=0.{}", format!("{:03}", x).trim_right_matches('0')), + x => write!(f, "; q=0.{}", format!("{:03}", x).trim_end_matches('0')), } } } diff --git a/src/request.rs b/src/request.rs index 0ea251ea0..a645c7aeb 100644 --- a/src/request.rs +++ b/src/request.rs @@ -103,7 +103,7 @@ impl

Request

{ } /// Mutable reference to the message's headers. - fn headers_mut(&mut self) -> &mut HeaderMap { + pub fn headers_mut(&mut self) -> &mut HeaderMap { &mut self.head_mut().headers } diff --git a/src/test.rs b/src/test.rs index 4b925d020..e2e0fd76e 100644 --- a/src/test.rs +++ b/src/test.rs @@ -46,7 +46,6 @@ struct Inner { headers: HeaderMap, _cookies: Option>>, payload: Option, - prefix: u16, } impl Default for TestRequest { @@ -58,7 +57,6 @@ impl Default for TestRequest { headers: HeaderMap::new(), _cookies: None, payload: None, - prefix: 0, })) } } diff --git a/src/ws/client/mod.rs b/src/ws/client/mod.rs index 12c7229b9..8e59e846d 100644 --- a/src/ws/client/mod.rs +++ b/src/ws/client/mod.rs @@ -25,20 +25,6 @@ impl Protocol { } } - fn is_http(self) -> bool { - match self { - Protocol::Https | Protocol::Http => true, - _ => false, - } - } - - fn is_secure(self) -> bool { - match self { - Protocol::Https | Protocol::Wss => true, - _ => false, - } - } - fn port(self) -> u16 { match self { Protocol::Http | Protocol::Ws => 80,