diff options
author | Alan Du <alanhdu@gmail.com> | 2017-06-01 11:38:56 +0100 |
---|---|---|
committer | Alan Du <alanhdu@gmail.com> | 2017-06-01 12:42:16 +0100 |
commit | ba505647f21a1355e1f36e2263fe6fd639adc38a (patch) | |
tree | 7f9a3428ad4d886691a0067c61567e1a19d8d598 /src | |
parent | 71b5310234964d22331c9ce59972f8a3026da61a (diff) | |
download | milf-rs-ba505647f21a1355e1f36e2263fe6fd639adc38a.tar.gz milf-rs-ba505647f21a1355e1f36e2263fe6fd639adc38a.zip |
Close #180
Diffstat (limited to 'src')
-rw-r--r-- | src/ser.rs | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -308,8 +308,28 @@ impl<'a> Serializer<'a> { State::Array { .. } => true, _ => false, }; + + // Unlike [..]s, we can't omit [[..]] ancestors, so be sure to emit table + // headers for them. + let mut p = state; + if let State::Array { first, parent, .. } = *state { + if first.get() { + p = parent; + } + } + while let State::Table { first, parent, .. } = *p { + p = parent; + if !first.get() { + break; + } + if let State::Array { parent: &State::Table {..}, ..} = *parent { + self.emit_table_header(parent)?; + break; + } + } + match *state { - State::Table { first , .. } | + State::Table { first, .. } | State::Array { parent: &State::Table { first, .. }, .. } => { if !first.get() { self.dst.push_str("\n"); |