diff --git a/examples/state/src/main.rs b/examples/state/src/main.rs index 21eb5048..a981c7fb 100644 --- a/examples/state/src/main.rs +++ b/examples/state/src/main.rs @@ -46,7 +46,7 @@ impl Handler for MyWebSocket { ws::Message::Ping(msg) => ctx.pong(&msg), ws::Message::Text(text) => ctx.text(text), ws::Message::Binary(bin) => ctx.binary(bin), - ws::Message::Closed | ws::Message::Error => { + ws::Message::Close(_) | ws::Message::Error => { ctx.stop(); } _ => (), diff --git a/examples/websocket-chat/src/main.rs b/examples/websocket-chat/src/main.rs index 821fcfa5..50e6bff5 100644 --- a/examples/websocket-chat/src/main.rs +++ b/examples/websocket-chat/src/main.rs @@ -161,10 +161,9 @@ impl Handler for WsChatSession { }, ws::Message::Binary(bin) => println!("Unexpected binary"), - ws::Message::Closed | ws::Message::Error => { + ws::Message::Close(_) | ws::Message::Error => { ctx.stop(); } - _ => (), } } } diff --git a/examples/websocket/src/main.rs b/examples/websocket/src/main.rs index 9149ead7..620e56d4 100644 --- a/examples/websocket/src/main.rs +++ b/examples/websocket/src/main.rs @@ -35,7 +35,7 @@ impl Handler for MyWebSocket { ws::Message::Ping(msg) => ctx.pong(&msg), ws::Message::Text(text) => ctx.text(text), ws::Message::Binary(bin) => ctx.binary(bin), - ws::Message::Closed | ws::Message::Error => { + ws::Message::Close(_) | ws::Message::Error => { ctx.stop(); } _ => (), diff --git a/src/application.rs b/src/application.rs index c7c1bcac..f8ac85c9 100644 --- a/src/application.rs +++ b/src/application.rs @@ -149,7 +149,7 @@ impl Application where S: 'static { pub fn with_state(state: S) -> Application { Application { parts: Some(ApplicationParts { - state: state, + state, prefix: "/".to_owned(), settings: ServerSettings::default(), default: Resource::default_not_found(), @@ -361,17 +361,17 @@ impl Application where S: 'static { default: parts.default, encoding: parts.encoding, router: router.clone(), - resources: resources, handlers: parts.handlers, + resources, } )); HttpApplication { state: Rc::new(parts.state), prefix: prefix.to_owned(), - inner: inner, router: router.clone(), middlewares: Rc::new(parts.middlewares), + inner, } } diff --git a/src/client/parser.rs b/src/client/parser.rs index 6a0ee108..31c6601a 100644 --- a/src/client/parser.rs +++ b/src/client/parser.rs @@ -176,12 +176,12 @@ impl HttpResponseParser { if let Some(decoder) = decoder { Ok(Async::Ready( (ClientResponse::new( - ClientMessage{status: status, version: version, + ClientMessage{status, version, headers: hdrs, cookies: None}), Some(decoder)))) } else { Ok(Async::Ready( (ClientResponse::new( - ClientMessage{status: status, version: version, + ClientMessage{status, version, headers: hdrs, cookies: None}), None))) } } diff --git a/src/client/pipeline.rs b/src/client/pipeline.rs index 46705134..dfb01bd6 100644 --- a/src/client/pipeline.rs +++ b/src/client/pipeline.rs @@ -63,16 +63,13 @@ impl SendRequest { pub(crate) fn with_connector(req: ClientRequest, conn: Addr) -> SendRequest { - SendRequest{ - req: req, - state: State::New, - conn: conn} + SendRequest{req, conn, state: State::New} } pub(crate) fn with_connection(req: ClientRequest, conn: Connection) -> SendRequest { SendRequest{ - req: req, + req, state: State::Connection(conn), conn: ClientConnector::from_registry()} } @@ -103,7 +100,7 @@ impl Future for SendRequest { Err(_) => return Err(SendRequestError::Connector( ClientConnectorError::Disconnected)) }, - State::Connection(stream) => { + State::Connection(conn) => { let mut writer = HttpClientWriter::new(SharedBytes::default()); writer.start(&mut self.req)?; @@ -114,9 +111,7 @@ impl Future for SendRequest { }; let mut pl = Box::new(Pipeline { - body: body, - conn: stream, - writer: writer, + body, conn, writer, parser: Some(HttpResponseParser::default()), parser_buf: BytesMut::new(), disconnected: false, @@ -221,11 +216,10 @@ impl Pipeline { let mut need_run = false; // need write? - match self.poll_write() + if let Async::NotReady = self.poll_write() .map_err(|e| io::Error::new(io::ErrorKind::Other, format!("{}", e)))? { - Async::NotReady => need_run = true, - _ => (), + need_run = true; } // need read? diff --git a/src/client/writer.rs b/src/client/writer.rs index ad1bb6a1..f072ea7f 100644 --- a/src/client/writer.rs +++ b/src/client/writer.rs @@ -1,4 +1,6 @@ +#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))] #![allow(dead_code)] + use std::io::{self, Write}; use std::cell::RefCell; use std::fmt::Write as FmtWrite; @@ -48,14 +50,14 @@ pub(crate) struct HttpClientWriter { impl HttpClientWriter { - pub fn new(buf: SharedBytes) -> HttpClientWriter { - let encoder = ContentEncoder::Identity(TransferEncoding::eof(buf.clone())); + pub fn new(buffer: SharedBytes) -> HttpClientWriter { + let encoder = ContentEncoder::Identity(TransferEncoding::eof(buffer.clone())); HttpClientWriter { flags: Flags::empty(), written: 0, headers_size: 0, - buffer: buf, - encoder: encoder, + buffer, + encoder, low: LOW_WATERMARK, high: HIGH_WATERMARK, } diff --git a/src/context.rs b/src/context.rs index a3e168f6..02eda8d5 100644 --- a/src/context.rs +++ b/src/context.rs @@ -230,10 +230,7 @@ pub struct Drain { impl Drain { pub fn new(fut: oneshot::Receiver<()>) -> Self { - Drain { - fut: fut, - _a: PhantomData - } + Drain { fut, _a: PhantomData } } } diff --git a/src/error.rs b/src/error.rs index f9436203..4cc67486 100644 --- a/src/error.rs +++ b/src/error.rs @@ -90,7 +90,7 @@ impl From for Error { } else { None }; - Error { cause: Box::new(err), backtrace: backtrace } + Error { cause: Box::new(err), backtrace } } } @@ -566,10 +566,10 @@ unsafe impl Sync for InternalError {} unsafe impl Send for InternalError {} impl InternalError { - pub fn new(err: T, status: StatusCode) -> Self { + pub fn new(cause: T, status: StatusCode) -> Self { InternalError { - cause: err, - status: status, + cause, + status, backtrace: Backtrace::new(), } } diff --git a/src/fs.rs b/src/fs.rs index 28260e36..b7588dc5 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -105,10 +105,7 @@ pub struct Directory{ impl Directory { pub fn new(base: PathBuf, path: PathBuf) -> Directory { - Directory { - base: base, - path: path - } + Directory { base, path } } fn can_list(&self, entry: &io::Result) -> bool { diff --git a/src/handler.rs b/src/handler.rs index 253024e6..b8e07472 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -215,7 +215,7 @@ impl WrapHandler S: 'static, { pub fn new(h: H) -> Self { - WrapHandler{h: h, s: PhantomData} + WrapHandler{h, s: PhantomData} } } @@ -225,7 +225,7 @@ impl RouteHandler for WrapHandler S: 'static, { fn handle(&mut self, req: HttpRequest) -> Reply { - let req2 = req.clone_without_state(); + let req2 = req.without_state(); match self.h.handle(req).respond_to(req2) { Ok(reply) => reply.into(), Err(err) => Reply::response(err.into()), @@ -266,7 +266,7 @@ impl RouteHandler for AsyncHandler S: 'static, { fn handle(&mut self, req: HttpRequest) -> Reply { - let req2 = req.clone_without_state(); + let req2 = req.without_state(); let fut = (self.h)(req) .map_err(|e| e.into()) .then(move |r| { @@ -345,10 +345,10 @@ impl NormalizePath { /// Create new `NormalizePath` instance pub fn new(append: bool, merge: bool, redirect: StatusCode) -> NormalizePath { NormalizePath { - append: append, - merge: merge, + append, + merge, + redirect, re_merge: Regex::new("//+").unwrap(), - redirect: redirect, not_found: StatusCode::NOT_FOUND, } } diff --git a/src/httprequest.rs b/src/httprequest.rs index 3ca4fdf9..3e6000b5 100644 --- a/src/httprequest.rs +++ b/src/httprequest.rs @@ -106,16 +106,16 @@ impl HttpRequest<()> { { HttpRequest( SharedHttpMessage::from_message(HttpMessage { - method: method, - uri: uri, - version: version, - headers: headers, + method, + uri, + version, + headers, + payload, params: Params::new(), query: Params::new(), query_loaded: false, cookies: None, addr: None, - payload: payload, extensions: Extensions::new(), info: None, }), @@ -153,7 +153,7 @@ impl HttpRequest { #[inline] /// Construct new http request without state. - pub(crate) fn clone_without_state(&self) -> HttpRequest { + pub(crate) fn without_state(&self) -> HttpRequest { HttpRequest(self.0.clone(), None, None) } @@ -483,7 +483,7 @@ impl HttpRequest { /// # fn main() {} /// ``` pub fn body(self) -> RequestBody { - RequestBody::from(self) + RequestBody::new(self.without_state()) } /// Return stream to http payload processes as multipart. @@ -553,7 +553,7 @@ impl HttpRequest { /// # fn main() {} /// ``` pub fn urlencoded(self) -> UrlEncoded { - UrlEncoded::from(self) + UrlEncoded::new(self.without_state()) } /// Parse `application/json` encoded body. @@ -677,9 +677,9 @@ pub struct UrlEncoded { } impl UrlEncoded { - pub fn from(req: HttpRequest) -> UrlEncoded { + pub fn new(req: HttpRequest) -> UrlEncoded { UrlEncoded { - req: Some(req.clone_without_state()), + req: Some(req), limit: 262_144, fut: None, } @@ -762,10 +762,10 @@ pub struct RequestBody { impl RequestBody { /// Create `RequestBody` for request. - pub fn from(req: HttpRequest) -> RequestBody { + pub fn new(req: HttpRequest) -> RequestBody { RequestBody { limit: 262_144, - req: Some(req.clone_without_state()), + req: Some(req), fut: None, } } diff --git a/src/httpresponse.rs b/src/httpresponse.rs index 77b63f12..cf702c67 100644 --- a/src/httpresponse.rs +++ b/src/httpresponse.rs @@ -659,11 +659,11 @@ impl InnerHttpResponse { #[inline] fn new(status: StatusCode, body: Body) -> InnerHttpResponse { InnerHttpResponse { + status, + body, version: None, headers: HeaderMap::with_capacity(16), - status: status, reason: None, - body: body, chunked: None, encoding: None, connection_type: None, diff --git a/src/info.rs b/src/info.rs index 92ffa4d6..45bd4fe6 100644 --- a/src/info.rs +++ b/src/info.rs @@ -110,8 +110,8 @@ impl<'a> ConnectionInfo<'a> { ConnectionInfo { scheme: scheme.unwrap_or("http"), host: host.unwrap_or("localhost"), - remote: remote, - peer: peer, + remote, + peer, } } diff --git a/src/lib.rs b/src/lib.rs index 7ec67565..eb0da3c3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,7 +32,7 @@ //! * Supported *HTTP/1.x* and *HTTP/2.0* protocols //! * Streaming and pipelining //! * Keep-alive and slow requests handling -//! * *WebSockets* server/client +//! * `WebSockets` server/client //! * Transparent content compression/decompression (br, gzip, deflate) //! * Configurable request routing //! * Multipart streams diff --git a/src/middleware/defaultheaders.rs b/src/middleware/defaultheaders.rs index 4e4686ca..344c69a6 100644 --- a/src/middleware/defaultheaders.rs +++ b/src/middleware/defaultheaders.rs @@ -95,7 +95,7 @@ impl DefaultHeadersBuilder { /// Finishes building and returns the built `DefaultHeaders` middleware. pub fn finish(&mut self) -> DefaultHeaders { let headers = self.headers.take().expect("cannot reuse middleware builder"); - DefaultHeaders{ ct: self.ct, headers: headers } + DefaultHeaders{ ct: self.ct, headers } } } diff --git a/src/middleware/session.rs b/src/middleware/session.rs index ad865669..b46cd49e 100644 --- a/src/middleware/session.rs +++ b/src/middleware/session.rs @@ -377,8 +377,8 @@ impl SessionBackend for CookieSessionBackend { FutOk( CookieSession { changed: false, - state: state, inner: Rc::clone(&self.0), + state, }) } } diff --git a/src/multipart.rs b/src/multipart.rs index 457fe4be..6211f611 100644 --- a/src/multipart.rs +++ b/src/multipart.rs @@ -95,8 +95,8 @@ impl Multipart where S: Stream { safety: Safety::new(), inner: Some(Rc::new(RefCell::new( InnerMultipart { + boundary, payload: PayloadRef::new(PayloadHelper::new(stream)), - boundary: boundary, state: InnerState::FirstBoundary, item: InnerMultipartItem::None, }))) @@ -369,12 +369,7 @@ impl Field where S: Stream { fn new(safety: Safety, headers: HeaderMap, ct: mime::Mime, inner: Rc>>) -> Self { - Field { - ct: ct, - headers: headers, - inner: inner, - safety: safety, - } + Field {ct, headers, inner, safety} } pub fn headers(&self) -> &HeaderMap { @@ -443,8 +438,8 @@ impl InnerField where S: Stream { }; Ok(InnerField { + boundary, payload: Some(payload), - boundary: boundary, eof: false, length: len }) } @@ -596,7 +591,7 @@ impl Safety { Safety { task: None, level: Rc::strong_count(&payload), - payload: payload, + payload, } } @@ -612,7 +607,7 @@ impl Clone for Safety { Safety { task: Some(current_task()), level: Rc::strong_count(&payload), - payload: payload, + payload, } } } diff --git a/src/payload.rs b/src/payload.rs index e4ba819d..664004d7 100644 --- a/src/payload.rs +++ b/src/payload.rs @@ -232,8 +232,8 @@ impl Inner { fn new(eof: bool) -> Self { Inner { + eof, len: 0, - eof: eof, err: None, task: None, items: VecDeque::new(), diff --git a/src/pipeline.rs b/src/pipeline.rs index 2408bf93..2fd21ec2 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -72,7 +72,7 @@ struct PipelineInfo { impl PipelineInfo { fn new(req: HttpRequest) -> PipelineInfo { PipelineInfo { - req: req, + req, count: 0, mws: Rc::new(Vec::new()), error: None, @@ -108,9 +108,8 @@ impl> Pipeline { handler: Rc>) -> Pipeline { let mut info = PipelineInfo { - req: req, + req, mws, count: 0, - mws: mws, error: None, context: None, disconnected: None, @@ -307,7 +306,7 @@ impl WaitingResponse { RunMiddlewares::init(info, resp), ReplyItem::Future(fut) => PipelineState::Handler( - WaitingResponse { fut: fut, _s: PhantomData, _h: PhantomData }), + WaitingResponse { fut, _s: PhantomData, _h: PhantomData }), } } @@ -355,7 +354,7 @@ impl RunMiddlewares { }, Ok(Response::Future(fut)) => { return PipelineState::RunMiddlewares( - RunMiddlewares { curr: curr, fut: Some(fut), + RunMiddlewares { curr, fut: Some(fut), _s: PhantomData, _h: PhantomData }) }, }; @@ -444,7 +443,7 @@ impl ProcessResponse { #[inline] fn init(resp: HttpResponse) -> PipelineState { PipelineState::Response( - ProcessResponse{ resp: resp, + ProcessResponse{ resp, iostate: IOState::Response, running: RunningState::Running, drain: None, _s: PhantomData, _h: PhantomData}) @@ -644,7 +643,7 @@ impl FinishingMiddlewares { if info.count == 0 { Completed::init(info) } else { - let mut state = FinishingMiddlewares{resp: resp, fut: None, + let mut state = FinishingMiddlewares{resp, fut: None, _s: PhantomData, _h: PhantomData}; if let Some(st) = state.poll(info) { st diff --git a/src/route.rs b/src/route.rs index bd721b1c..b4d1d268 100644 --- a/src/route.rs +++ b/src/route.rs @@ -179,14 +179,10 @@ impl Compose { mws: Rc>>>, handler: InnerHandler) -> Self { - let mut info = ComposeInfo { - count: 0, - req: req, - mws: mws, - handler: handler }; + let mut info = ComposeInfo { count: 0, req, mws, handler }; let state = StartMiddlewares::init(&mut info); - Compose {state: state, info: info} + Compose {state, info} } } @@ -308,7 +304,7 @@ impl WaitingResponse { RunMiddlewares::init(info, resp), ReplyItem::Future(fut) => ComposeState::Handler( - WaitingResponse { fut: fut, _s: PhantomData }), + WaitingResponse { fut, _s: PhantomData }), } } @@ -353,7 +349,7 @@ impl RunMiddlewares { }, Ok(MiddlewareResponse::Future(fut)) => { return ComposeState::RunMiddlewares( - RunMiddlewares { curr: curr, fut: Some(fut), _s: PhantomData }) + RunMiddlewares { curr, fut: Some(fut), _s: PhantomData }) }, }; } diff --git a/src/router.rs b/src/router.rs index 9f1d93b0..63cc9045 100644 --- a/src/router.rs +++ b/src/router.rs @@ -46,13 +46,9 @@ impl Router { } } - let len = prefix.len(); + let prefix_len = prefix.len(); (Router(Rc::new( - Inner{ prefix: prefix, - prefix_len: len, - named: named, - patterns: patterns, - srv: settings })), resources) + Inner{ prefix, prefix_len, named, patterns, srv: settings })), resources) } /// Router prefix @@ -168,10 +164,10 @@ impl Pattern { }; Pattern { - tp: tp, + tp, + pattern, + elements, name: name.into(), - pattern: pattern, - elements: elements, } } diff --git a/src/server/channel.rs b/src/server/channel.rs index 85c3ac4e..8cf23ed3 100644 --- a/src/server/channel.rs +++ b/src/server/channel.rs @@ -237,7 +237,7 @@ pub(crate) struct WrapperStream where T: AsyncRead + AsyncWrite + 'static { impl WrapperStream where T: AsyncRead + AsyncWrite + 'static { pub fn new(io: T) -> Self { - WrapperStream{io: io} + WrapperStream{ io } } } diff --git a/src/server/encoding.rs b/src/server/encoding.rs index 9137bb42..d2b2db93 100644 --- a/src/server/encoding.rs +++ b/src/server/encoding.rs @@ -309,7 +309,7 @@ pub(crate) struct EncodedPayload { impl EncodedPayload { pub fn new(inner: PayloadSender, enc: ContentEncoding) -> EncodedPayload { - EncodedPayload{ inner: inner, error: false, payload: PayloadStream::new(enc) } + EncodedPayload{ inner, error: false, payload: PayloadStream::new(enc) } } } @@ -821,10 +821,7 @@ impl AcceptEncoding { Err(_) => 0.0, } }; - Some(AcceptEncoding { - encoding: encoding, - quality: quality, - }) + Some(AcceptEncoding{ encoding, quality }) } /// Parse a raw Accept-Encoding header value into an ordered list. diff --git a/src/server/h1.rs b/src/server/h1.rs index 4ce403cb..527eec67 100644 --- a/src/server/h1.rs +++ b/src/server/h1.rs @@ -1,3 +1,5 @@ +#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))] + use std::{self, io}; use std::rc::Rc; use std::net::SocketAddr; @@ -62,18 +64,20 @@ struct Entry { impl Http1 where T: IoStream, H: HttpHandler + 'static { - pub fn new(h: Rc>, stream: T, addr: Option, buf: BytesMut) - -> Self + pub fn new(settings: Rc>, + stream: T, + addr: Option, read_buf: BytesMut) -> Self { - let bytes = h.get_shared_bytes(); + let bytes = settings.get_shared_bytes(); Http1{ flags: Flags::KEEPALIVE, - settings: h, - addr: addr, stream: H1Writer::new(stream, bytes), reader: Reader::new(), - read_buf: buf, tasks: VecDeque::new(), - keepalive_timer: None } + keepalive_timer: None, + addr, + read_buf, + settings, + } } pub fn settings(&self) -> &WorkerSettings { @@ -540,7 +544,7 @@ impl Reader { let (psender, payload) = Payload::new(false); let info = PayloadInfo { tx: PayloadType::new(&msg.get_mut().headers, psender), - decoder: decoder, + decoder, }; msg.get_mut().payload = Some(payload); Ok(Async::Ready((HttpRequest::from_message(msg), Some(info)))) diff --git a/src/server/h1writer.rs b/src/server/h1writer.rs index b2b79c5f..da60e220 100644 --- a/src/server/h1writer.rs +++ b/src/server/h1writer.rs @@ -1,3 +1,5 @@ +#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))] + use std::{io, mem}; use bytes::BufMut; use futures::{Async, Poll}; @@ -39,11 +41,11 @@ impl H1Writer { pub fn new(stream: T, buf: SharedBytes) -> H1Writer { H1Writer { flags: Flags::empty(), - stream: stream, encoder: ContentEncoder::empty(buf.clone()), written: 0, headers_size: 0, buffer: buf, + stream, } } diff --git a/src/server/h2.rs b/src/server/h2.rs index c843fee8..0a387525 100644 --- a/src/server/h2.rs +++ b/src/server/h2.rs @@ -1,3 +1,5 @@ +#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))] + use std::{io, cmp, mem}; use std::rc::Rc; use std::io::{Read, Write}; @@ -53,15 +55,17 @@ impl Http2 where T: AsyncRead + AsyncWrite + 'static, H: HttpHandler + 'static { - pub fn new(h: Rc>, io: T, addr: Option, buf: Bytes) -> Self + pub fn new(settings: Rc>, + io: T, + addr: Option, buf: Bytes) -> Self { Http2{ flags: Flags::empty(), - settings: h, - addr: addr, tasks: VecDeque::new(), state: State::Handshake( server::handshake(IoWrapper{unread: Some(buf), inner: io})), keepalive_timer: None, + addr, + settings, } } @@ -286,10 +290,10 @@ impl Entry { Entry {task: task.unwrap_or_else(|| Pipeline::error(HTTPNotFound)), payload: psender, - recv: recv, stream: H2Writer::new(resp, settings.get_shared_bytes()), flags: EntryFlags::empty(), capacity: 0, + recv, } } diff --git a/src/server/h2writer.rs b/src/server/h2writer.rs index 466f6520..29b53467 100644 --- a/src/server/h2writer.rs +++ b/src/server/h2writer.rs @@ -1,3 +1,5 @@ +#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))] + use std::{io, cmp}; use bytes::{Bytes, BytesMut}; use futures::{Async, Poll}; @@ -38,7 +40,7 @@ impl H2Writer { pub fn new(respond: SendResponse, buf: SharedBytes) -> H2Writer { H2Writer { - respond: respond, + respond, stream: None, encoder: ContentEncoder::empty(buf.clone()), flags: Flags::empty(), diff --git a/src/server/settings.rs b/src/server/settings.rs index 0ca4b437..33e6fa8d 100644 --- a/src/server/settings.rs +++ b/src/server/settings.rs @@ -36,11 +36,7 @@ impl ServerSettings { } else { "localhost".to_owned() }; - ServerSettings { - addr: addr, - secure: secure, - host: host, - } + ServerSettings { addr, secure, host } } /// Returns the socket address of the local half of this TCP connection diff --git a/src/server/worker.rs b/src/server/worker.rs index 23e8a6c6..5257d861 100644 --- a/src/server/worker.rs +++ b/src/server/worker.rs @@ -62,7 +62,7 @@ impl Worker { Worker { settings: Rc::new(WorkerSettings::new(h, keep_alive)), hnd: Arbiter::handle().clone(), - handler: handler, + handler, } } diff --git a/src/test.rs b/src/test.rs index fe3422b5..b1d467b6 100644 --- a/src/test.rs +++ b/src/test.rs @@ -94,12 +94,12 @@ impl TestServer { let _ = sys.run(); }); - let (sys, addr) = rx.recv().unwrap(); + let (server_sys, addr) = rx.recv().unwrap(); TestServer { - addr: addr, + addr, thread: Some(join), system: System::new("actix-test"), - server_sys: sys, + server_sys, } } @@ -131,12 +131,12 @@ impl TestServer { let _ = sys.run(); }); - let (sys, addr) = rx.recv().unwrap(); + let (server_sys, addr) = rx.recv().unwrap(); TestServer { - addr: addr, + addr, + server_sys, thread: Some(join), system: System::new("actix-test"), - server_sys: sys, } } @@ -346,7 +346,7 @@ impl TestRequest { /// Start HttpRequest build process with application state pub fn with_state(state: S) -> TestRequest { TestRequest { - state: state, + state, method: Method::GET, uri: Uri::from_str("/").unwrap(), version: Version::HTTP_11, @@ -434,7 +434,7 @@ impl TestRequest { let req = self.finish(); let resp = h.handle(req.clone()); - match resp.respond_to(req.clone_without_state()) { + match resp.respond_to(req.without_state()) { Ok(resp) => { match resp.into().into() { ReplyItem::Message(resp) => Ok(resp), @@ -461,7 +461,7 @@ impl TestRequest { let mut core = Core::new().unwrap(); match core.run(fut) { Ok(r) => { - match r.respond_to(req.clone_without_state()) { + match r.respond_to(req.without_state()) { Ok(reply) => match reply.into().into() { ReplyItem::Message(resp) => Ok(resp), _ => panic!("Nested async replies are not supported"), diff --git a/src/ws/client.rs b/src/ws/client.rs index 369b5631..4b2a3b44 100644 --- a/src/ws/client.rs +++ b/src/ws/client.rs @@ -130,7 +130,7 @@ impl WsClient { http_err: None, origin: None, protocols: None, - conn: conn, + conn, }; cl.request.uri(uri.as_ref()); cl @@ -253,7 +253,7 @@ impl WsHandshake { io::ErrorKind::Other, "disconnected").into())))); WsHandshake { - key: key, + key, inner: None, request: Some(request.with_connector(conn.clone())), tx: Some(tx), @@ -261,7 +261,7 @@ impl WsHandshake { } } else { WsHandshake { - key: key, + key, inner: None, request: None, tx: None, @@ -340,7 +340,7 @@ impl Future for WsHandshake { let inner = Rc::new(UnsafeCell::new(inner)); Ok(Async::Ready( - (WsClientReader{inner: Rc::clone(&inner)}, WsClientWriter{inner: inner}))) + (WsClientReader{inner: Rc::clone(&inner)}, WsClientWriter{inner}))) } } diff --git a/src/ws/frame.rs b/src/ws/frame.rs index 22067cb6..7c573b71 100644 --- a/src/ws/frame.rs +++ b/src/ws/frame.rs @@ -146,13 +146,7 @@ impl Frame { } Ok(Async::Ready(Some(Frame { - finished: finished, - rsv1: rsv1, - rsv2: rsv2, - rsv3: rsv3, - opcode: opcode, - payload: data.into(), - }))) + finished, rsv1, rsv2, rsv3, opcode, payload: data.into() }))) } /// Generate binary representation