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 {
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||||
let mut f = Pretty::from(f);
|
let mut f = Pretty::from(f);
|
||||||
f.write_char('[')?;
|
f.write_char('[')?;
|
||||||
|
if !self.is_empty() {
|
||||||
let indent = pretty_indent();
|
let indent = pretty_indent();
|
||||||
write!(f, "{}", Fmt::pretty_comma_separated(self.as_slice()))?;
|
write!(f, "{}", Fmt::pretty_comma_separated(self.as_slice()))?;
|
||||||
drop(indent);
|
drop(indent);
|
||||||
|
}
|
||||||
f.write_char(']')
|
f.write_char(']')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,6 +144,7 @@ impl Display for Object {
|
||||||
} else {
|
} else {
|
||||||
f.write_str("{ ")?;
|
f.write_str("{ ")?;
|
||||||
}
|
}
|
||||||
|
if !self.is_empty() {
|
||||||
let indent = pretty_indent();
|
let indent = pretty_indent();
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
|
@ -158,6 +159,7 @@ impl Display for Object {
|
||||||
)
|
)
|
||||||
)?;
|
)?;
|
||||||
drop(indent);
|
drop(indent);
|
||||||
|
}
|
||||||
if is_pretty() {
|
if is_pretty() {
|
||||||
f.write_char('}')
|
f.write_char('}')
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue