Skip to content

Commit 7fde9ba

Browse files
committed
refactor(body): improve Debug format of Body
1 parent 778421e commit 7fde9ba

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/body/body.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,21 @@ impl Stream for Body {
343343

344344
impl fmt::Debug for Body {
345345
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
346-
f.debug_struct("Body").finish()
346+
#[derive(Debug)]
347+
struct Streaming;
348+
#[derive(Debug)]
349+
struct Empty;
350+
#[derive(Debug)]
351+
struct Once<'a>(&'a Chunk);
352+
353+
let mut builder = f.debug_tuple("Body");
354+
match self.kind {
355+
Kind::Once(None) => builder.field(&Empty),
356+
Kind::Once(Some(ref chunk)) => builder.field(&Once(chunk)),
357+
_ => builder.field(&Streaming),
358+
};
359+
360+
builder.finish()
347361
}
348362
}
349363

0 commit comments

Comments
 (0)