Skip to content

Commit

Permalink
fix: Sane default array decor (toml-rs#207)
Browse files Browse the repository at this point in the history
When porting cargo-edit to toml_edit 0.3, I found the default array
formatting is off.  This is because our `Display` doesn't have
knowledge of its context.  Generally, the caller knows better what the
default decode should be.

This adds a new trait for encoding which allows the caller to pass in
the needed context.
  • Loading branch information
epage authored Sep 14, 2021
1 parent e6c4ce4 commit 6c5de21
Show file tree
Hide file tree
Showing 7 changed files with 272 additions and 251 deletions.
6 changes: 6 additions & 0 deletions src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ impl Array {
}
}

impl std::fmt::Display for Array {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
crate::encode::Encode::encode(self, f, ("", ""))
}
}

impl<V: Into<Value>> Extend<V> for Array {
fn extend<T: IntoIterator<Item = V>>(&mut self, iter: T) {
for value in iter {
Expand Down
Loading

0 comments on commit 6c5de21

Please sign in to comment.