Apply a couple trivial clippy suggestions

pull/7/head
Ran Benita 8 years ago
parent 8955b55e62
commit ae30b8cd76
  1. 2
      src/client.rs
  2. 15
      src/protocol/mod.rs

@ -57,7 +57,7 @@ fn wrap_stream(stream: TcpStream, domain: &str, mode: Mode) -> Result<AutoStream
TlsHandshakeError::Failure(f) => f.into(), TlsHandshakeError::Failure(f) => f.into(),
TlsHandshakeError::Interrupted(_) => panic!("Bug: TLS handshake not blocked"), TlsHandshakeError::Interrupted(_) => panic!("Bug: TLS handshake not blocked"),
}) })
.map(|s| StreamSwitcher::Tls(s)) .map(StreamSwitcher::Tls)
} }
} }
} }

@ -124,15 +124,12 @@ impl<Stream: Read + Write> WebSocket<Stream> {
/// This function guarantees that the close frame will be queued. /// This function guarantees that the close frame will be queued.
/// There is no need to call it again, just like write_message(). /// There is no need to call it again, just like write_message().
pub fn close(&mut self) -> Result<()> { pub fn close(&mut self) -> Result<()> {
match self.state { if let WebSocketState::Active = self.state {
WebSocketState::Active => { self.state = WebSocketState::ClosedByUs;
self.state = WebSocketState::ClosedByUs; let frame = Frame::close(None);
let frame = Frame::close(None); self.send_queue.push_back(frame);
self.send_queue.push_back(frame); } else {
} // Already closed, nothing to do.
_ => {
// already closed, nothing to do
}
} }
self.write_pending() self.write_pending()
} }

Loading…
Cancel
Save