From d383a061e1ba0bbd029b3ffb4bf23f155cb563ae Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Mon, 7 Aug 2017 17:48:37 -0700 Subject: [PATCH] customize Debug for request/response Parts --- src/request.rs | 14 +++++++++++++- src/response.rs | 13 ++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/request.rs b/src/request.rs index 7b7c483..cd32b23 100644 --- a/src/request.rs +++ b/src/request.rs @@ -164,7 +164,6 @@ pub struct Request { /// /// The HTTP request head consists of a method, uri, version, and a set of /// header fields. -#[derive(Debug)] pub struct Parts { /// The request's method pub method: Method, @@ -486,6 +485,19 @@ impl Parts { } } +impl fmt::Debug for Parts { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Parts") + .field("method", &self.method) + .field("uri", &self.uri) + .field("version", &self.version) + .field("headers", &self.headers) + // omits Extensions because not useful + // omits _priv because not useful + .finish() + } +} + impl Builder { /// Creates a new default instance of `Builder` to construct either a /// `Head` or a `Request`. diff --git a/src/response.rs b/src/response.rs index 8e60ac3..183e2f6 100644 --- a/src/response.rs +++ b/src/response.rs @@ -191,7 +191,6 @@ pub struct Response { /// /// The HTTP response head consists of a status, version, and a set of /// header fields. -#[derive(Debug)] pub struct Parts { /// The response's status pub status: StatusCode, @@ -481,6 +480,18 @@ impl Parts { } } +impl fmt::Debug for Parts { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Parts") + .field("status", &self.status) + .field("version", &self.version) + .field("headers", &self.headers) + // omits Extensions because not useful + // omits _priv because not useful + .finish() + } +} + impl Builder { /// Creates a new default instance of `Builder` to construct either a /// `Head` or a `Response`.