8000 feat(edit): Add ImDocument::into_table (#928) · toml-rs/toml@f3e8c68 · GitHub
[go: up one dir, main page]

Skip to conten 10000 t

Commit f3e8c68

Browse files
authored
feat(edit): Add ImDocument::into_table (#928)
Fixes #926
2 parents 288161b + 32d2297 commit f3e8c68

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

crates/toml_edit/src/document.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,23 @@ impl<S> ImDocument<S> {
4343
&self.root
4444
}
4545

46+
/// Returns the root item.
47+
pub fn into_item(self) -> Item {
48+
self.root
49+
}
50+
4651
/// Returns a reference to the root table.
4752
pub fn as_table(&self) -> &Table {
4853
self.root.as_table().expect("root should always be a table")
4954
}
5055

56+
/// Returns the root table.
57+
pub fn into_table(self) -> Table {
58+
self.root
59+
.into_table()
60+
.expect("root should always be a table")
61+
}
62+
5163
/// Returns an iterator over the root table.
5264
pub fn iter(&self) -> Iter<'_> {
5365
self.as_table().iter()
@@ -129,6 +141,11 @@ impl DocumentMut {
129141
&mut self.root
130142
}
131143

144+
/// Returns the root item.
145+
pub fn into_item(self) -> Item {
146+
self.root
147+
}
148+
132149
/// Returns a reference to the root table.
133150
pub fn as_table(&self) -> &Table {
134151
self.root.as_table().expect("root should always be a table")
@@ -141,6 +158,13 @@ impl DocumentMut {
141158
.expect("root should always be a table")
142159
}
143160

161+
/// Returns the root table.
162+
pub fn into_table(self) -> Table {
163+
self.root
164+
.into_table()
165+
.expect("root should always be a table")
166+
}
167+
144168
/// Returns an iterator over the root table.
145169
pub fn iter(&self) -> Iter<'_> {
146170
self.as_table().iter()

0 commit comments

Comments
 (0)
0