From 0793764dcda369ddce6a134acc7a021e45d47764 Mon Sep 17 00:00:00 2001 From: Naja Melan Date: Sat, 10 Aug 2019 19:19:55 +0200 Subject: [PATCH 1/2] Add `dyn` to silence compiler warnings --- src/connect.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/connect.rs b/src/connect.rs index dfb44de..5a083de 100644 --- a/src/connect.rs +++ b/src/connect.rs @@ -67,7 +67,7 @@ mod encryption { } pub fn wrap_stream(socket: S, domain: String, mode: Mode) - -> Box, Error=Error> + Send> + -> Box, Error=Error> + Send> where S: 'static + AsyncRead + AsyncWrite + Send, { @@ -123,7 +123,7 @@ fn domain(request: &Request) -> Result { /// Creates a WebSocket handshake from a request and a stream, /// upgrading the stream to TLS if required. pub fn client_async_tls(request: R, stream: S) - -> Box>, Response), Error=Error> + Send> + -> Box>, Response), Error=Error> + Send> where R: Into>, S: 'static + AsyncRead + AsyncWrite + NoDelay + Send, @@ -152,7 +152,7 @@ where /// Connect to a given URL. pub fn connect_async(request: R) - -> Box>, Response), Error=Error> + Send> + -> Box>, Response), Error=Error> + Send> where R: Into> { From 380f531d8649fd16e34ad1bfd63f339d6b16193d Mon Sep 17 00:00:00 2001 From: Naja Melan Date: Sat, 10 Aug 2019 19:23:00 +0200 Subject: [PATCH 2/2] Fix some clippy warnings about unnecessary closures for more concise code --- src/connect.rs | 6 +++--- src/lib.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/connect.rs b/src/connect.rs index 5a083de..2189eb4 100644 --- a/src/connect.rs +++ b/src/connect.rs @@ -77,8 +77,8 @@ mod encryption { Box::new(future::result(TlsConnector::new()) .map(TokioTlsConnector::from) .and_then(move |connector| connector.connect(&domain, socket)) - .map(|s| StreamSwitcher::Tls(s)) - .map_err(|e| Error::Tls(e))) + .map(StreamSwitcher::Tls) + .map_err(Error::Tls)) } } } @@ -138,7 +138,7 @@ where // Make sure we check domain and mode first. URL must be valid. let mode = match url_mode(&request.url) { Ok(m) => m, - Err(e) => return Box::new(future::err(e.into())), + Err(e) => return Box::new(future::err(e)), }; Box::new(wrap_stream(stream, domain, mode) diff --git a/src/lib.rs b/src/lib.rs index 52f1697..fb70c47 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -215,7 +215,7 @@ impl Stream for WebSocketStream where T: AsyncRead + AsyncWrite { fn poll(&mut self) -> Poll, WsError> { self.inner .read_message() - .map(|msg| Some(msg)) + .map(Some) .to_async() .or_else(|err| match err { WsError::ConnectionClosed => Ok(Async::Ready(None)),