1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-30 18:34:36 +01:00

fix warnings

This commit is contained in:
Nikolay Kim 2019-03-06 21:12:35 -08:00
parent b689bb9260
commit e25483a0d5
6 changed files with 5 additions and 31 deletions

View File

@ -970,23 +970,13 @@ where
#[cfg(feature = "fail")] #[cfg(feature = "fail")]
mod failure_integration { mod failure_integration {
use super::*; use super::*;
use failure::{self, Fail};
/// Compatibility for `failure::Error` /// Compatibility for `failure::Error`
impl<T> ResponseError for failure::Compat<T> impl ResponseError for failure::Error {
where
T: fmt::Display + fmt::Debug + Sync + Send + 'static,
{
fn error_response(&self) -> Response { fn error_response(&self) -> Response {
Response::new(StatusCode::INTERNAL_SERVER_ERROR) Response::new(StatusCode::INTERNAL_SERVER_ERROR)
} }
} }
impl From<failure::Error> for Error {
fn from(err: failure::Error) -> Error {
err.compat().into()
}
}
} }
#[cfg(test)] #[cfg(test)]

View File

@ -27,7 +27,7 @@ fn split_once(haystack: &str, needle: char) -> (&str, &str) {
/// first part and the left of the last part. /// first part and the left of the last part.
fn split_once_and_trim(haystack: &str, needle: char) -> (&str, &str) { fn split_once_and_trim(haystack: &str, needle: char) -> (&str, &str) {
let (first, last) = split_once(haystack, needle); 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. /// 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 = &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. // In fact, it should not be Err if the above code is correct.
String::from_utf8(quoted_string) String::from_utf8(quoted_string)
.map_err(|_| crate::error::ParseError::Header)? .map_err(|_| crate::error::ParseError::Header)?

View File

@ -58,7 +58,7 @@ impl<T: fmt::Display> fmt::Display for QualityItem<T> {
match self.quality.0 { match self.quality.0 {
1000 => Ok(()), 1000 => Ok(()),
0 => f.write_str("; q=0"), 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')),
} }
} }
} }

View File

@ -103,7 +103,7 @@ impl<P> Request<P> {
} }
/// Mutable reference to the message's headers. /// 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 &mut self.head_mut().headers
} }

View File

@ -46,7 +46,6 @@ struct Inner {
headers: HeaderMap, headers: HeaderMap,
_cookies: Option<Vec<Cookie<'static>>>, _cookies: Option<Vec<Cookie<'static>>>,
payload: Option<Payload>, payload: Option<Payload>,
prefix: u16,
} }
impl Default for TestRequest { impl Default for TestRequest {
@ -58,7 +57,6 @@ impl Default for TestRequest {
headers: HeaderMap::new(), headers: HeaderMap::new(),
_cookies: None, _cookies: None,
payload: None, payload: None,
prefix: 0,
})) }))
} }
} }

View File

@ -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 { fn port(self) -> u16 {
match self { match self {
Protocol::Http | Protocol::Ws => 80, Protocol::Http | Protocol::Ws => 80,