1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-24 07:53:00 +01:00

clippy warnings

This commit is contained in:
Nikolay Kim 2018-06-17 03:26:34 +06:00
parent f3a73d7dde
commit a7a062fb68
2 changed files with 75 additions and 72 deletions

View File

@ -3,7 +3,7 @@ use encoding::all::UTF_8;
use encoding::label::encoding_from_whatwg_label; use encoding::label::encoding_from_whatwg_label;
use encoding::types::{DecoderTrap, Encoding}; use encoding::types::{DecoderTrap, Encoding};
use encoding::EncodingRef; use encoding::EncodingRef;
use futures::{Future, Poll, Stream, Async}; use futures::{Async, Future, Poll, Stream};
use http::{header, HeaderMap}; use http::{header, HeaderMap};
use http_range::HttpRange; use http_range::HttpRange;
use mime::Mime; use mime::Mime;
@ -12,8 +12,8 @@ use serde_urlencoded;
use std::str; use std::str;
use error::{ use error::{
ContentTypeError, HttpRangeError, ParseError, PayloadError, UrlencodedError, ContentTypeError, HttpRangeError, ParseError, PayloadError, ReadlinesError,
ReadlinesError UrlencodedError,
}; };
use header::Header; use header::Header;
use json::JsonBody; use json::JsonBody;
@ -316,7 +316,7 @@ where
if !self.checked_buff { if !self.checked_buff {
let mut found: Option<usize> = None; let mut found: Option<usize> = None;
for (ind, b) in self.buff.iter().enumerate() { for (ind, b) in self.buff.iter().enumerate() {
if *b == '\n' as u8 { if *b == b'\n' {
found = Some(ind); found = Some(ind);
break; break;
} }
@ -346,7 +346,7 @@ where
// check if there is a newline in bytes // check if there is a newline in bytes
let mut found: Option<usize> = None; let mut found: Option<usize> = None;
for (ind, b) in bytes.iter().enumerate() { for (ind, b) in bytes.iter().enumerate() {
if *b == '\n' as u8 { if *b == b'\n' {
found = Some(ind); found = Some(ind);
break; break;
} }
@ -373,10 +373,10 @@ where
} }
self.buff.extend_from_slice(&bytes); self.buff.extend_from_slice(&bytes);
Ok(Async::NotReady) Ok(Async::NotReady)
}, }
Ok(Async::NotReady) => Ok(Async::NotReady), Ok(Async::NotReady) => Ok(Async::NotReady),
Ok(Async::Ready(None)) => { Ok(Async::Ready(None)) => {
if self.buff.len() == 0 { if self.buff.is_empty() {
return Ok(Async::Ready(None)); return Ok(Async::Ready(None));
} }
if self.buff.len() > self.limit { if self.buff.len() > self.limit {
@ -393,8 +393,8 @@ where
.map_err(|_| ReadlinesError::EncodingError)? .map_err(|_| ReadlinesError::EncodingError)?
}; };
self.buff.clear(); self.buff.clear();
return Ok(Async::Ready(Some(line))) Ok(Async::Ready(Some(line)))
}, }
Err(e) => Err(ReadlinesError::from(e)), Err(e) => Err(ReadlinesError::from(e)),
} }
} }
@ -812,22 +812,28 @@ mod tests {
req.payload_mut().unread_data(Bytes::from_static( req.payload_mut().unread_data(Bytes::from_static(
b"Lorem Ipsum is simply dummy text of the printing and typesetting\n\ b"Lorem Ipsum is simply dummy text of the printing and typesetting\n\
industry. Lorem Ipsum has been the industry's standard dummy\n\ industry. Lorem Ipsum has been the industry's standard dummy\n\
Contrary to popular belief, Lorem Ipsum is not simply random text." Contrary to popular belief, Lorem Ipsum is not simply random text.",
)); ));
let mut r = Readlines::new(req); let mut r = Readlines::new(req);
match r.poll().ok().unwrap() { match r.poll().ok().unwrap() {
Async::Ready(Some(s)) => assert_eq!(s, Async::Ready(Some(s)) => assert_eq!(
"Lorem Ipsum is simply dummy text of the printing and typesetting\n"), s,
"Lorem Ipsum is simply dummy text of the printing and typesetting\n"
),
_ => unreachable!("error"), _ => unreachable!("error"),
} }
match r.poll().ok().unwrap() { match r.poll().ok().unwrap() {
Async::Ready(Some(s)) => assert_eq!(s, Async::Ready(Some(s)) => assert_eq!(
"industry. Lorem Ipsum has been the industry's standard dummy\n"), s,
"industry. Lorem Ipsum has been the industry's standard dummy\n"
),
_ => unreachable!("error"), _ => unreachable!("error"),
} }
match r.poll().ok().unwrap() { match r.poll().ok().unwrap() {
Async::Ready(Some(s)) => assert_eq!(s, Async::Ready(Some(s)) => assert_eq!(
"Contrary to popular belief, Lorem Ipsum is not simply random text."), s,
"Contrary to popular belief, Lorem Ipsum is not simply random text."
),
_ => unreachable!("error"), _ => unreachable!("error"),
} }
} }

View File

@ -615,8 +615,7 @@ impl<H: IntoHttpHandler> Handler<signal::Signal> for HttpServer<H> {
/// Commands from accept threads /// Commands from accept threads
impl<H: IntoHttpHandler> StreamHandler<ServerCommand, ()> for HttpServer<H> { impl<H: IntoHttpHandler> StreamHandler<ServerCommand, ()> for HttpServer<H> {
fn handle(&mut self, msg: Result<Option<ServerCommand>, ()>, _: &mut Context<Self>) { fn handle(&mut self, msg: Result<Option<ServerCommand>, ()>, _: &mut Context<Self>) {
match msg { if let Ok(Some(ServerCommand::WorkerDied(idx, socks))) = msg {
Ok(Some(ServerCommand::WorkerDied(idx, socks))) => {
let mut found = false; let mut found = false;
for i in 0..self.workers.len() { for i in 0..self.workers.len() {
if self.workers[i].0 == idx { if self.workers[i].0 == idx {
@ -662,8 +661,6 @@ impl<H: IntoHttpHandler> StreamHandler<ServerCommand, ()> for HttpServer<H> {
self.workers.push((new_idx, addr)); self.workers.push((new_idx, addr));
} }
} }
_ => (),
}
} }
} }