Skip to content

Commit

Permalink
Close toml-rs#180
Browse files Browse the repository at this point in the history
  • Loading branch information
alanhdu committed Jun 1, 2017
1 parent 71b5310 commit ba50564
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit ba50564

Please sign in to comment.