Skip to content

Commit

Permalink
refactor(body): improve Debug format of Body
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Apr 30, 2019
1 parent 778421e commit 7fde9ba
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/body/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,21 @@ impl Stream for Body {

impl fmt::Debug for Body {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Body").finish()
#[derive(Debug)]
struct Streaming;
#[derive(Debug)]
struct Empty;
#[derive(Debug)]
struct Once<'a>(&'a Chunk);

let mut builder = f.debug_tuple("Body");
match self.kind {
Kind::Once(None) => builder.field(&Empty),
Kind::Once(Some(ref chunk)) => builder.field(&Once(chunk)),
_ => builder.field(&Streaming),
};

builder.finish()
}
}

Expand Down

0 comments on commit 7fde9ba

Please sign in to comment.