aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2017-08-13 18:15:41 -0500
committerGitHub <noreply@github.com>2017-08-13 18:15:41 -0500
commit4b3139e2b66896376dd257040014a313db5fcc1e (patch)
tree835a99a14d0b789b580351bab1e8a4a3a3d8ce96 /src
parentea251b375316fab8c9c87726751d9a3014b38ed7 (diff)
parenta0d0a313dfbcffa33942c0d2f1a6dd337f350ceb (diff)
downloadmilf-rs-4b3139e2b66896376dd257040014a313db5fcc1e.tar.gz
milf-rs-4b3139e2b66896376dd257040014a313db5fcc1e.zip
Merge pull request #207 from vitiral/array-spaces
add spaces between array items and test for them
Diffstat (limited to 'src')
-rw-r--r--src/ser.rs21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/ser.rs b/src/ser.rs
index 13d4584..3c4c220 100644
--- a/src/ser.rs
+++ b/src/ser.rs
@@ -628,12 +628,25 @@ impl<'a> Serializer<'a> {
}
match *state {
- State::Table { first, .. } |
- State::Array { parent: &State::Table { first, .. }, .. } => {
+ State::Table { first, .. } => {
if !first.get() {
- self.dst.push_str("\n");
+ // Newline if we are a table that is not the first
+ // table in the document.
+ self.dst.push('\n');
}
- }
+ },
+ State::Array { parent, first, .. } => {
+ if !first.get() {
+ // Always newline if we are not the first item in the
+ // table-array
+ self.dst.push('\n');
+ } else if let State::Table { first, .. } = *parent {
+ if !first.get() {
+ // Newline if we are not the first item in the document
+ self.dst.push('\n');
+ }
+ }
+ },
_ => {}
}
self.dst.push_str("[");