From ba505647f21a1355e1f36e2263fe6fd639adc38a Mon Sep 17 00:00:00 2001 From: Alan Du Date: Thu, 1 Jun 2017 11:38:56 +0100 Subject: Close #180 --- src/ser.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ser.rs b/src/ser.rs index 22eda81..8f6b366 100644 --- a/src/ser.rs +++ b/src/ser.rs @@ -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"); -- cgit v1.2.3