Skip to content

Commit

Permalink
fix(edit): Allow creating Tables from Items
Browse files Browse the repository at this point in the history
As `From<_> for Item` forwards to `From<_> for Value`, this shouldn't be
a breaking change.

Fixes #785
  • Loading branch information
epage committed Sep 16, 2024
1 parent fe18d4e commit f8e909c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/toml_edit/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,17 +442,17 @@ impl std::fmt::Display for Table {
}
}

impl<K: Into<Key>, V: Into<Value>> Extend<(K, V)> for Table {
impl<K: Into<Key>, V: Into<Item>> Extend<(K, V)> for Table {
fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T) {
for (key, value) in iter {
let key = key.into();
let value = Item::Value(value.into());
let value = value.into();
self.items.insert(key, value);
}
}
}

impl<K: Into<Key>, V: Into<Value>> FromIterator<(K, V)> for Table {
impl<K: Into<Key>, V: Into<Item>> FromIterator<(K, V)> for Table {
fn from_iter<I>(iter: I) -> Self
where
I: IntoIterator<Item = (K, V)>,
Expand Down

0 comments on commit f8e909c

Please sign in to comment.