Don’t pretty print newlines in objects and arrays if empty
This commit is contained in:
parent
40e75f3f35
commit
7413e93a48
2 changed files with 21 additions and 17 deletions
|
@ -153,9 +153,11 @@ impl Display for Array {
|
|||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||
let mut f = Pretty::from(f);
|
||||
f.write_char('[')?;
|
||||
if !self.is_empty() {
|
||||
let indent = pretty_indent();
|
||||
write!(f, "{}", Fmt::pretty_comma_separated(self.as_slice()))?;
|
||||
drop(indent);
|
||||
}
|
||||
f.write_char(']')
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,6 +144,7 @@ impl Display for Object {
|
|||
} else {
|
||||
f.write_str("{ ")?;
|
||||
}
|
||||
if !self.is_empty() {
|
||||
let indent = pretty_indent();
|
||||
write!(
|
||||
f,
|
||||
|
@ -158,6 +159,7 @@ impl Display for Object {
|
|||
)
|
||||
)?;
|
||||
drop(indent);
|
||||
}
|
||||
if is_pretty() {
|
||||
f.write_char('}')
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue