diff --git a/src/client.rs b/src/client.rs index 63e4d8f..8d98600 100644 --- a/src/client.rs +++ b/src/client.rs @@ -57,7 +57,7 @@ fn wrap_stream(stream: TcpStream, domain: &str, mode: Mode) -> Result f.into(), TlsHandshakeError::Interrupted(_) => panic!("Bug: TLS handshake not blocked"), }) - .map(|s| StreamSwitcher::Tls(s)) + .map(StreamSwitcher::Tls) } } } diff --git a/src/protocol/mod.rs b/src/protocol/mod.rs index 970d99e..b03d954 100644 --- a/src/protocol/mod.rs +++ b/src/protocol/mod.rs @@ -124,15 +124,12 @@ impl WebSocket { /// This function guarantees that the close frame will be queued. /// There is no need to call it again, just like write_message(). pub fn close(&mut self) -> Result<()> { - match self.state { - WebSocketState::Active => { - self.state = WebSocketState::ClosedByUs; - let frame = Frame::close(None); - self.send_queue.push_back(frame); - } - _ => { - // already closed, nothing to do - } + if let WebSocketState::Active = self.state { + self.state = WebSocketState::ClosedByUs; + let frame = Frame::close(None); + self.send_queue.push_back(frame); + } else { + // Already closed, nothing to do. } self.write_pending() }