Skip to content

Commit

Permalink
refactor: Consolidate on join implementations (toml-rs#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
epage authored Sep 3, 2021
1 parent 79b084c commit d1adb91
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl Display for Array {
"{}[",
self.decor.prefix().unwrap_or(DEFAULT_VALUE_DECOR.0)
)?;
join(f, self.iter(), ",")?;
write!(f, "{}", self.iter().join(","))?;
if self.trailing_comma {
write!(f, ",")?;
}
Expand Down Expand Up @@ -245,17 +245,3 @@ impl Display for Document {
self.trailing.fmt(f)
}
}

fn join<D, I>(f: &mut Formatter<'_>, iter: I, sep: &str) -> Result
where
D: Display,
I: Iterator<Item = D>,
{
for (i, v) in iter.enumerate() {
if i > 0 {
write!(f, "{}", sep)?;
}
write!(f, "{}", v)?;
}
Ok(())
}

0 comments on commit d1adb91

Please sign in to comment.