diff --git a/src/client.rs b/src/client.rs index f4c5f8d..41a813d 100644 --- a/src/client.rs +++ b/src/client.rs @@ -103,7 +103,7 @@ pub fn connect_with_config( ) -> Result<(WebSocket, Response)> { let uri = request.uri(); let mode = uri_mode(uri)?; - let host = request.uri().host().ok_or_else(|| Error::Url(UrlErrorType::NoHostName))?; + let host = request.uri().host().ok_or(Error::Url(UrlErrorType::NoHostName))?; let port = uri.port_u16().unwrap_or(match mode { Mode::Plain => 80, Mode::Tls => 443, @@ -165,7 +165,7 @@ pub fn connect(request: Req) -> Result<(WebSocket Result { - let domain = uri.host().ok_or_else(|| Error::Url(UrlErrorType::NoHostName))?; + let domain = uri.host().ok_or(Error::Url(UrlErrorType::NoHostName))?; for addr in addrs { debug!("Trying to contact {} at {}...", uri, addr); if let Ok(raw_stream) = TcpStream::connect(addr) { diff --git a/src/handshake/client.rs b/src/handshake/client.rs index e7247d9..5b9f934 100644 --- a/src/handshake/client.rs +++ b/src/handshake/client.rs @@ -97,7 +97,7 @@ fn generate_request(request: Request, key: &str) -> Result> { let mut req = Vec::new(); let uri = request.uri(); - let authority = uri.authority().ok_or_else(|| Error::Url(UrlErrorType::NoHostName))?.as_str(); + let authority = uri.authority().ok_or(Error::Url(UrlErrorType::NoHostName))?.as_str(); let host = if let Some(idx) = authority.find('@') { // handle possible name:password@ authority.split_at(idx + 1).1 @@ -119,8 +119,7 @@ fn generate_request(request: Request, key: &str) -> Result> { Sec-WebSocket-Key: {key}\r\n", version = request.version(), host = host, - path = - uri.path_and_query().ok_or_else(|| Error::Url(UrlErrorType::NoPathOrQuery))?.as_str(), + path = uri.path_and_query().ok_or(Error::Url(UrlErrorType::NoPathOrQuery))?.as_str(), key = key ) .unwrap(); diff --git a/src/handshake/server.rs b/src/handshake/server.rs index c7877bc..372bff7 100644 --- a/src/handshake/server.rs +++ b/src/handshake/server.rs @@ -68,7 +68,7 @@ fn create_parts(request: &HttpRequest) -> Result { let key = request .headers() .get("Sec-WebSocket-Key") - .ok_or_else(|| Error::Protocol(ProtocolErrorType::MissingSecWebSocketKey))?; + .ok_or(Error::Protocol(ProtocolErrorType::MissingSecWebSocketKey))?; let builder = Response::builder() .status(StatusCode::SWITCHING_PROTOCOLS)