Repository: websockets-rs/rust-websocket (language: rust)

Issue:
#[derive(Debug)] (or impl Debug) for websocket::server::InvalidConnection<tokio_core::net::TcpStream, bytes::bytes::BytesMut>
Currently one can not use `unwrap()` on the result in order to quickly prototype.

```
   = note: the method `unwrap` exists but the following trait bounds were not satisfied:
           `websocket::server::InvalidConnection<tokio_core::net::TcpStream, bytes::bytes::BytesMut> : std::fmt::Debug`
```


Discussion / hints:
@Kixunil unfortunately this cannot have `Debug` in it because `TcpStream` does not implement `Debug`.
Would simply having a custom implementation that says `TcpStream -> "TcpStream"` be OK?
Sure. It may also skip TcpStream entirely or provide address. Having information about why something failed is what's needed.

Fix patch:
diff --git a/src/server/mod.rs b/src/server/mod.rs
index aa5f375473..d7f33f2ab7 100644
--- a/src/server/mod.rs
+++ b/src/server/mod.rs
@@ -3,6 +3,7 @@
 use native_tls::TlsAcceptor;
 
 use self::upgrade::{HyperIntoWsError, Request};
+use std::fmt::{Debug, Formatter, Result as FmtResult};
 use stream::Stream;
 
 pub mod upgrade;
@@ -48,6 +49,20 @@ where
 	pub error: HyperIntoWsError,
 }
 
+impl<S, B> Debug for InvalidConnection<S, B>
+where
+	S: Stream,
+{
+	fn fmt(&self, fmt: &mut Formatter<'_>) -> FmtResult {
+		fmt.debug_struct("InvalidConnection")
+			.field("stream", &String::from("..."))
+			.field("parsed", &String::from("..."))
+			.field("buffer", &String::from("..."))
+			.field("error", &self.error)
+			.finish()
+	}
+}
+
 /// Represents a WebSocket server which can work with either normal
 /// (non-secure) connections, or secure WebSocket connections.
 ///


Test patch: