From 003b05b095e9b6f63b03341df5ba4dcae7554215 Mon Sep 17 00:00:00 2001 From: Maciej Piechotka Date: Tue, 11 Sep 2018 13:57:55 +0200 Subject: [PATCH] Don't ignore errors in std::fmt::Debug implementations (#506) --- src/client/request.rs | 20 ++++++++++---------- src/client/response.rs | 8 ++++---- src/httprequest.rs | 14 +++++++------- src/multipart.rs | 10 +++++----- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/client/request.rs b/src/client/request.rs index aff4ab48..76fb1be5 100644 --- a/src/client/request.rs +++ b/src/client/request.rs @@ -254,16 +254,16 @@ impl ClientRequest { impl fmt::Debug for ClientRequest { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let res = writeln!( + writeln!( f, "\nClientRequest {:?} {}:{}", self.version, self.method, self.uri - ); - let _ = writeln!(f, " headers:"); + )?; + writeln!(f, " headers:")?; for (key, val) in self.headers.iter() { - let _ = writeln!(f, " {:?}: {:?}", key, val); + writeln!(f, " {:?}: {:?}", key, val)?; } - res + Ok(()) } } @@ -750,16 +750,16 @@ fn parts<'a>( impl fmt::Debug for ClientRequestBuilder { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if let Some(ref parts) = self.request { - let res = writeln!( + writeln!( f, "\nClientRequestBuilder {:?} {}:{}", parts.version, parts.method, parts.uri - ); - let _ = writeln!(f, " headers:"); + )?; + writeln!(f, " headers:")?; for (key, val) in parts.headers.iter() { - let _ = writeln!(f, " {:?}: {:?}", key, val); + writeln!(f, " {:?}: {:?}", key, val)?; } - res + Ok(()) } else { write!(f, "ClientRequestBuilder(Consumed)") } diff --git a/src/client/response.rs b/src/client/response.rs index 0c094a2a..5f1f4264 100644 --- a/src/client/response.rs +++ b/src/client/response.rs @@ -95,12 +95,12 @@ impl ClientResponse { impl fmt::Debug for ClientResponse { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let res = writeln!(f, "\nClientResponse {:?} {}", self.version(), self.status()); - let _ = writeln!(f, " headers:"); + writeln!(f, "\nClientResponse {:?} {}", self.version(), self.status())?; + writeln!(f, " headers:")?; for (key, val) in self.headers().iter() { - let _ = writeln!(f, " {:?}: {:?}", key, val); + writeln!(f, " {:?}: {:?}", key, val)?; } - res + Ok(()) } } diff --git a/src/httprequest.rs b/src/httprequest.rs index f4de8152..d8c49496 100644 --- a/src/httprequest.rs +++ b/src/httprequest.rs @@ -354,24 +354,24 @@ impl FromRequest for HttpRequest { impl fmt::Debug for HttpRequest { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let res = writeln!( + writeln!( f, "\nHttpRequest {:?} {}:{}", self.version(), self.method(), self.path() - ); + )?; if !self.query_string().is_empty() { - let _ = writeln!(f, " query: ?{:?}", self.query_string()); + writeln!(f, " query: ?{:?}", self.query_string())?; } if !self.match_info().is_empty() { - let _ = writeln!(f, " params: {:?}", self.match_info()); + writeln!(f, " params: {:?}", self.match_info())?; } - let _ = writeln!(f, " headers:"); + writeln!(f, " headers:")?; for (key, val) in self.headers().iter() { - let _ = writeln!(f, " {:?}: {:?}", key, val); + writeln!(f, " {:?}: {:?}", key, val)?; } - res + Ok(()) } } diff --git a/src/multipart.rs b/src/multipart.rs index fe809294..862f60ec 100644 --- a/src/multipart.rs +++ b/src/multipart.rs @@ -441,13 +441,13 @@ where impl fmt::Debug for Field { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let res = writeln!(f, "\nMultipartField: {}", self.ct); - let _ = writeln!(f, " boundary: {}", self.inner.borrow().boundary); - let _ = writeln!(f, " headers:"); + writeln!(f, "\nMultipartField: {}", self.ct)?; + writeln!(f, " boundary: {}", self.inner.borrow().boundary)?; + writeln!(f, " headers:")?; for (key, val) in self.headers.iter() { - let _ = writeln!(f, " {:?}: {:?}", key, val); + writeln!(f, " {:?}: {:?}", key, val)?; } - res + Ok(()) } }