From fcf1debe21ac55f27b1fa7789ce50a27681af4ad Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 11 Mar 2024 10:14:10 -0500 Subject: [PATCH] refactor(edit): Remove unused raw field on Document --- crates/toml_edit/src/de/mod.rs | 4 ++-- crates/toml_edit/src/document.rs | 5 ----- crates/toml_edit/src/encode.rs | 12 ++---------- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/crates/toml_edit/src/de/mod.rs b/crates/toml_edit/src/de/mod.rs index 1355a53b..f920764e 100644 --- a/crates/toml_edit/src/de/mod.rs +++ b/crates/toml_edit/src/de/mod.rs @@ -141,8 +141,8 @@ impl> Deserializer { impl From for Deserializer { fn from(doc: crate::Document) -> Self { - let crate::Document { root, raw, .. } = doc; - Self { root, raw } + let crate::Document { root, .. } = doc; + Self { root, raw: None } } } diff --git a/crates/toml_edit/src/document.rs b/crates/toml_edit/src/document.rs index 8367c545..44840027 100644 --- a/crates/toml_edit/src/document.rs +++ b/crates/toml_edit/src/document.rs @@ -73,9 +73,6 @@ impl> ImDocument { Document { root: self.root, trailing: self.trailing, - // prevent a child of `ImDocument` from being inserted into `Document` and having the - // spans evaluated when using `crate::encode` - raw: None, } } } @@ -114,7 +111,6 @@ pub struct Document { pub(crate) root: Item, // Trailing comments and whitespaces pub(crate) trailing: RawString, - pub(crate) raw: Option, } impl Document { @@ -166,7 +162,6 @@ impl Default for Document { Self { root: Item::Table(Table::with_pos(Some(0))), trailing: Default::default(), - raw: Default::default(), } } } diff --git a/crates/toml_edit/src/encode.rs b/crates/toml_edit/src/encode.rs index 4d8cef30..ec323213 100644 --- a/crates/toml_edit/src/encode.rs +++ b/crates/toml_edit/src/encode.rs @@ -212,17 +212,9 @@ impl Display for Document { tables.sort_by_key(|&(id, _, _, _)| id); let mut first_table = true; for (_, table, path, is_array) in tables { - visit_table( - f, - self.raw.as_deref(), - table, - &path, - is_array, - &mut first_table, - )?; + visit_table(f, None, table, &path, is_array, &mut first_table)?; } - self.trailing() - .encode_with_default(f, self.raw.as_deref(), "") + self.trailing().encode_with_default(f, None, "") } }