diff --git a/crates/benchmarks/benches/cargo.rs b/crates/benchmarks/benches/cargo.rs index ae403f6c..954135c4 100644 --- a/crates/benchmarks/benches/cargo.rs +++ b/crates/benchmarks/benches/cargo.rs @@ -2,7 +2,7 @@ mod toml_edit { use super::*; #[divan::bench(args=MANIFESTS)] - fn document(sample: &Data) -> ::toml_edit::Document { + fn document(sample: &Data) -> ::toml_edit::DocumentMut { sample.content().parse().unwrap() } diff --git a/crates/benchmarks/benches/linear.rs b/crates/benchmarks/benches/linear.rs index ae95db02..c66190a8 100644 --- a/crates/benchmarks/benches/linear.rs +++ b/crates/benchmarks/benches/linear.rs @@ -8,7 +8,7 @@ mod map { bencher .with_inputs(|| gen(num_entries)) .input_counter(divan::counter::BytesCount::of_str) - .bench_values(|sample| sample.parse::().unwrap()) + .bench_values(|sample| sample.parse::().unwrap()) } #[divan::bench(args = NUM_ENTRIES)] @@ -45,7 +45,7 @@ mod array { bencher .with_inputs(|| gen(num_entries)) .input_counter(divan::counter::BytesCount::of_str) - .bench_values(|sample| sample.parse::().unwrap()) + .bench_values(|sample| sample.parse::().unwrap()) } #[divan::bench(args = NUM_ENTRIES)] diff --git a/crates/benchmarks/examples/bench.rs b/crates/benchmarks/examples/bench.rs index 010c0924..0f7dc11c 100644 --- a/crates/benchmarks/examples/bench.rs +++ b/crates/benchmarks/examples/bench.rs @@ -3,7 +3,7 @@ fn main() -> Result<(), lexopt::Error> { match args.parser { Parser::Document => { - let _doc = CARGO_MANIFEST.parse::().unwrap(); + let _doc = CARGO_MANIFEST.parse::().unwrap(); #[cfg(debug_assertions)] // Don't interefere with profiling dbg!(_doc); } diff --git a/crates/toml/src/fmt.rs b/crates/toml/src/fmt.rs index 281cb59c..650ba4dc 100644 --- a/crates/toml/src/fmt.rs +++ b/crates/toml/src/fmt.rs @@ -5,7 +5,7 @@ pub(crate) struct DocumentFormatter { } impl toml_edit::visit_mut::VisitMut for DocumentFormatter { - fn visit_document_mut(&mut self, node: &mut toml_edit::Document) { + fn visit_document_mut(&mut self, node: &mut toml_edit::DocumentMut) { toml_edit::visit_mut::visit_document_mut(self, node); } diff --git a/crates/toml/src/ser.rs b/crates/toml/src/ser.rs index f1ab24bb..0406893b 100644 --- a/crates/toml/src/ser.rs +++ b/crates/toml/src/ser.rs @@ -61,7 +61,7 @@ where /// To serialize TOML values, instead of documents, see [`ValueSerializer`]. /// /// For greater customization, instead serialize to a -/// [`toml_edit::Document`](https://docs.rs/toml_edit/latest/toml_edit/struct.Document.html). +/// [`toml_edit::DocumentMut`](https://docs.rs/toml_edit/latest/toml_edit/struct.DocumentMut.html). #[cfg(feature = "display")] pub fn to_string_pretty(value: &T) -> Result where @@ -161,7 +161,7 @@ impl<'d> Serializer<'d> { /// Apply a default "pretty" policy to the document /// /// For greater customization, instead serialize to a - /// [`toml_edit::Document`](https://docs.rs/toml_edit/latest/toml_edit/struct.Document.html). + /// [`toml_edit::DocumentMut`](https://docs.rs/toml_edit/latest/toml_edit/struct.DocumentMut.html). pub fn pretty(dst: &'d mut String) -> Self { let mut ser = Serializer::new(dst); ser.settings.multiline_array = true; @@ -923,7 +923,7 @@ mod internal { use toml_edit::visit_mut::VisitMut as _; settings.visit_table_mut(&mut table); - let doc: toml_edit::Document = table.into(); + let doc: toml_edit::DocumentMut = table.into(); write!(dst, "{}", doc).unwrap(); Ok(()) diff --git a/crates/toml_edit/examples/visit.rs b/crates/toml_edit/examples/visit.rs index cd7f851f..13024c2f 100644 --- a/crates/toml_edit/examples/visit.rs +++ b/crates/toml_edit/examples/visit.rs @@ -3,7 +3,7 @@ use std::collections::BTreeSet; use toml_edit::visit::*; use toml_edit::visit_mut::*; -use toml_edit::{Array, Document, InlineTable, Item, KeyMut, Table, Value}; +use toml_edit::{Array, DocumentMut, InlineTable, Item, KeyMut, Table, Value}; /// This models the visit state for dependency keys in a `Cargo.toml`. /// @@ -223,7 +223,7 @@ cargo-test-macro = { path = "crates/cargo-test-macro" } flate2 = { version = "0.4" } "#; -fn visit_example(document: &Document) -> BTreeSet<&str> { +fn visit_example(document: &DocumentMut) -> BTreeSet<&str> { let mut visitor = DependencyNameVisitor { state: VisitState::Root, names: BTreeSet::new(), @@ -234,7 +234,7 @@ fn visit_example(document: &Document) -> BTreeSet<&str> { visitor.names } -fn visit_mut_example(document: &mut Document) { +fn visit_mut_example(document: &mut DocumentMut) { let mut visitor = NormalizeDependencyTablesVisitor { state: VisitState::Root, }; @@ -243,7 +243,7 @@ fn visit_mut_example(document: &mut Document) { } fn main() { - let mut document: Document = INPUT.parse().expect("input is valid TOML"); + let mut document: DocumentMut = INPUT.parse().expect("input is valid TOML"); println!("** visit example"); println!("{:?}", visit_example(&document)); @@ -256,7 +256,7 @@ fn main() { #[cfg(test)] #[test] fn visit_correct() { - let document: Document = INPUT.parse().expect("input is valid TOML"); + let document: DocumentMut = INPUT.parse().expect("input is valid TOML"); let names = visit_example(&document); let expected = vec![ @@ -277,7 +277,7 @@ fn visit_correct() { #[cfg(test)] #[test] fn visit_mut_correct() { - let mut document: Document = INPUT.parse().expect("input is valid TOML"); + let mut document: DocumentMut = INPUT.parse().expect("input is valid TOML"); visit_mut_example(&mut document); assert_eq!(format!("{}", document), VISIT_MUT_OUTPUT); diff --git a/crates/toml_edit/src/de/mod.rs b/crates/toml_edit/src/de/mod.rs index f920764e..739f8392 100644 --- a/crates/toml_edit/src/de/mod.rs +++ b/crates/toml_edit/src/de/mod.rs @@ -86,7 +86,7 @@ impl From for crate::TomlError { impl std::error::Error for Error {} -/// Convert a TOML [documents][crate::Document] into `T`. +/// Convert a TOML [documents][crate::DocumentMut] into `T`. #[cfg(feature = "parse")] pub fn from_str(s: &'_ str) -> Result where @@ -96,7 +96,7 @@ where T::deserialize(de) } -/// Convert a TOML [documents][crate::Document] into `T`. +/// Convert a TOML [documents][crate::DocumentMut] into `T`. #[cfg(feature = "parse")] pub fn from_slice(s: &'_ [u8]) -> Result where @@ -106,7 +106,7 @@ where from_str(s) } -/// Convert a [Document][crate::Document] into `T`. +/// Convert a [DocumentMut][crate::DocumentMut] into `T`. pub fn from_document(d: impl Into) -> Result where T: DeserializeOwned, @@ -115,7 +115,7 @@ where T::deserialize(deserializer) } -/// Deserialization for TOML [documents][crate::Document]. +/// Deserialization for TOML [documents][crate::DocumentMut]. pub struct Deserializer { root: crate::Item, raw: Option, @@ -124,7 +124,7 @@ pub struct Deserializer { impl Deserializer { /// Deserialization implementation for TOML. #[deprecated(since = "0.22.6", note = "Replaced with `Deserializer::from`")] - pub fn new(input: crate::Document) -> Self { + pub fn new(input: crate::DocumentMut) -> Self { Self::from(input) } } @@ -139,9 +139,9 @@ impl> Deserializer { } } -impl From for Deserializer { - fn from(doc: crate::Document) -> Self { - let crate::Document { root, .. } = doc; +impl From for Deserializer { + fn from(doc: crate::DocumentMut) -> Self { + let crate::DocumentMut { root, .. } = doc; Self { root, raw: None } } } @@ -272,7 +272,7 @@ impl<'de> serde::de::IntoDeserializer<'de, crate::de::Error> for Deserializer { } } -impl<'de> serde::de::IntoDeserializer<'de, crate::de::Error> for crate::Document { +impl<'de> serde::de::IntoDeserializer<'de, crate::de::Error> for crate::DocumentMut { type Deserializer = Deserializer; fn into_deserializer(self) -> Self::Deserializer { diff --git a/crates/toml_edit/src/document.rs b/crates/toml_edit/src/document.rs index 6a896545..40edf76d 100644 --- a/crates/toml_edit/src/document.rs +++ b/crates/toml_edit/src/document.rs @@ -30,7 +30,7 @@ impl> ImDocument { impl> ImDocument { /// # Panics /// - /// If run on on a `Document` not generated by the parser + /// If run on on a [`DocumentMut`] not generated by the parser pub(crate) fn despan(&mut self) { self.root.despan(self.raw.as_ref()); self.trailing.despan(self.raw.as_ref()); diff --git a/crates/toml_edit/src/encode.rs b/crates/toml_edit/src/encode.rs index b2ecc8c1..da8f1e24 100644 --- a/crates/toml_edit/src/encode.rs +++ b/crates/toml_edit/src/encode.rs @@ -10,7 +10,7 @@ use crate::table::{DEFAULT_KEY_DECOR, DEFAULT_KEY_PATH_DECOR, DEFAULT_TABLE_DECO use crate::value::{ DEFAULT_LEADING_VALUE_DECOR, DEFAULT_TRAILING_VALUE_DECOR, DEFAULT_VALUE_DECOR, }; -use crate::Document; +use crate::DocumentMut; use crate::{Array, InlineTable, Item, Table, Value}; pub(crate) fn encode_key(this: &Key, buf: &mut dyn Write, input: Option<&str>) -> Result { @@ -195,7 +195,7 @@ pub(crate) fn encode_value( } } -impl Display for Document { +impl Display for DocumentMut { fn fmt(&self, f: &mut Formatter<'_>) -> Result { let mut path = Vec::new(); let mut last_position = 0; diff --git a/crates/toml_edit/src/index.rs b/crates/toml_edit/src/index.rs index 93f84e78..cdf646fd 100644 --- a/crates/toml_edit/src/index.rs +++ b/crates/toml_edit/src/index.rs @@ -2,7 +2,7 @@ use std::ops; use crate::key::Key; use crate::table::TableKeyValue; -use crate::Document; +use crate::DocumentMut; use crate::{value, InlineTable, InternalString, Item, Table, Value}; // copied from @@ -141,7 +141,7 @@ impl<'s> ops::IndexMut<&'s str> for InlineTable { } } -impl<'s> ops::Index<&'s str> for Document { +impl<'s> ops::Index<&'s str> for DocumentMut { type Output = Item; fn index(&self, key: &'s str) -> &Item { @@ -149,7 +149,7 @@ impl<'s> ops::Index<&'s str> for Document { } } -impl<'s> ops::IndexMut<&'s str> for Document { +impl<'s> ops::IndexMut<&'s str> for DocumentMut { fn index_mut(&mut self, key: &'s str) -> &mut Item { self.root.index_mut(key) } diff --git a/crates/toml_edit/src/inline_table.rs b/crates/toml_edit/src/inline_table.rs index 316637d2..705c6679 100644 --- a/crates/toml_edit/src/inline_table.rs +++ b/crates/toml_edit/src/inline_table.rs @@ -148,8 +148,8 @@ impl InlineTable { /// ``` /// # #[cfg(feature = "parse")] { /// # #[cfg(feature = "display")] { - /// use toml_edit::Document; - /// let mut doc = "[a]\n[a.b]\n".parse::().expect("invalid toml"); + /// use toml_edit::DocumentMut; + /// let mut doc = "[a]\n[a.b]\n".parse::().expect("invalid toml"); /// /// doc["a"].as_table_mut().unwrap().set_implicit(true); /// assert_eq!(doc.to_string(), "[a.b]\n"); diff --git a/crates/toml_edit/src/lib.rs b/crates/toml_edit/src/lib.rs index c36fd98f..15c9fc24 100644 --- a/crates/toml_edit/src/lib.rs +++ b/crates/toml_edit/src/lib.rs @@ -16,13 +16,13 @@ //! ```rust //! # #[cfg(feature = "parse")] { //! # #[cfg(feature = "display")] { -//! use toml_edit::{Document, value}; +//! use toml_edit::{DocumentMut, value}; //! //! let toml = r#" //! "hello" = 'toml!' # comment //! ['a'.b] //! "#; -//! let mut doc = toml.parse::().expect("invalid doc"); +//! let mut doc = toml.parse::().expect("invalid doc"); //! assert_eq!(doc.to_string(), toml); //! // let's add a new key/value pair inside a.b: c = {d = "hello"} //! doc["a"]["b"]["c"]["d"] = value("hello"); @@ -43,7 +43,7 @@ //! By default, values are created with default formatting //! ```rust //! # #[cfg(feature = "display")] { -//! let mut doc = toml_edit::Document::new(); +//! let mut doc = toml_edit::DocumentMut::new(); //! doc["foo"] = toml_edit::value("bar"); //! let expected = r#"foo = "bar" //! "#; @@ -54,7 +54,7 @@ //! You can choose a custom TOML representation by parsing the value. //! ```rust //! # #[cfg(feature = "display")] { -//! let mut doc = toml_edit::Document::new(); +//! let mut doc = toml_edit::DocumentMut::new(); //! doc["foo"] = "'bar'".parse::().unwrap(); //! let expected = r#"foo = 'bar' //! "#; @@ -100,7 +100,8 @@ pub use crate::array::{Array, ArrayIntoIter, ArrayIter, ArrayIterMut}; pub use crate::array_of_tables::{ ArrayOfTables, ArrayOfTablesIntoIter, ArrayOfTablesIter, ArrayOfTablesIterMut, }; -/// Type representing a TOML document +/// Deprecated, replaced with [`DocumentMut`] +#[deprecated(since = "0.22.6", note = "Replaced with `DocumentMut`")] pub type Document = DocumentMut; pub use crate::document::DocumentMut; pub use crate::document::ImDocument; diff --git a/crates/toml_edit/src/raw_string.rs b/crates/toml_edit/src/raw_string.rs index 30581728..86b70c3e 100644 --- a/crates/toml_edit/src/raw_string.rs +++ b/crates/toml_edit/src/raw_string.rs @@ -22,7 +22,7 @@ impl RawString { /// Access the underlying string /// - /// This generally requires a [`Document`][crate::Document]. + /// This generally requires a [`DocumentMut`][crate::DocumentMut]. pub fn as_str(&self) -> Option<&str> { match &self.0 { RawStringInner::Empty => Some(""), diff --git a/crates/toml_edit/src/ser/mod.rs b/crates/toml_edit/src/ser/mod.rs index ba31708b..c6566d0b 100644 --- a/crates/toml_edit/src/ser/mod.rs +++ b/crates/toml_edit/src/ser/mod.rs @@ -153,7 +153,7 @@ where /// Serialize the given data structure into a TOML document. /// /// This would allow custom formatting to be applied, mixing with format preserving edits, etc. -pub fn to_document(value: &T) -> Result +pub fn to_document(value: &T) -> Result where T: serde::ser::Serialize, { diff --git a/crates/toml_edit/src/ser/pretty.rs b/crates/toml_edit/src/ser/pretty.rs index 2c22f680..05552bfa 100644 --- a/crates/toml_edit/src/ser/pretty.rs +++ b/crates/toml_edit/src/ser/pretty.rs @@ -1,7 +1,7 @@ pub(crate) struct Pretty; impl crate::visit_mut::VisitMut for Pretty { - fn visit_document_mut(&mut self, node: &mut crate::Document) { + fn visit_document_mut(&mut self, node: &mut crate::DocumentMut) { crate::visit_mut::visit_document_mut(self, node); } diff --git a/crates/toml_edit/src/table.rs b/crates/toml_edit/src/table.rs index cc0d2b2d..02c8b312 100644 --- a/crates/toml_edit/src/table.rs +++ b/crates/toml_edit/src/table.rs @@ -167,8 +167,8 @@ impl Table { /// ``` /// # #[cfg(feature = "parse")] { /// # #[cfg(feature = "display")] { - /// use toml_edit::Document; - /// let mut doc = "[a]\n[a.b]\n".parse::().expect("invalid toml"); + /// use toml_edit::DocumentMut; + /// let mut doc = "[a]\n[a.b]\n".parse::().expect("invalid toml"); /// /// doc["a"].as_table_mut().unwrap().set_implicit(true); /// assert_eq!(doc.to_string(), "[a.b]\n"); @@ -194,12 +194,12 @@ impl Table { self.dotted } - /// Sets the position of the `Table` within the `Document`. + /// Sets the position of the `Table` within the [`DocumentMut`][crate::DocumentMut]. pub fn set_position(&mut self, doc_position: usize) { self.doc_position = Some(doc_position); } - /// The position of the `Table` within the `Document`. + /// The position of the `Table` within the [`DocumentMut`][crate::DocumentMut]. /// /// Returns `None` if the `Table` was created manually (i.e. not via parsing) /// in which case its position is set automatically. This can be overridden with diff --git a/crates/toml_edit/src/visit.rs b/crates/toml_edit/src/visit.rs index 6d7be0b8..98ffe864 100644 --- a/crates/toml_edit/src/visit.rs +++ b/crates/toml_edit/src/visit.rs @@ -63,7 +63,7 @@ //! the-force = { value = "surrounds-you" } //! "#; //! -//! let mut document: Document = input.parse().unwrap(); +//! let mut document: DocumentMut = input.parse().unwrap(); //! let mut visitor = StringCollector::default(); //! visitor.visit_document(&document); //! @@ -75,14 +75,15 @@ //! [on GitHub](https://github.com/toml-rs/toml/blob/main/crates/toml_edit/examples/visit.rs). use crate::{ - Array, ArrayOfTables, Datetime, Document, Formatted, InlineTable, Item, Table, TableLike, Value, + Array, ArrayOfTables, Datetime, DocumentMut, Formatted, InlineTable, Item, Table, TableLike, + Value, }; /// Document tree traversal to mutate an exclusive borrow of a document tree in-place. /// /// See the [module documentation](self) for details. pub trait Visit<'doc> { - fn visit_document(&mut self, node: &'doc Document) { + fn visit_document(&mut self, node: &'doc DocumentMut) { visit_document(self, node); } @@ -139,7 +140,7 @@ pub trait Visit<'doc> { } } -pub fn visit_document<'doc, V>(v: &mut V, node: &'doc Document) +pub fn visit_document<'doc, V>(v: &mut V, node: &'doc DocumentMut) where V: Visit<'doc> + ?Sized, { diff --git a/crates/toml_edit/src/visit_mut.rs b/crates/toml_edit/src/visit_mut.rs index c823cfbc..1968477a 100644 --- a/crates/toml_edit/src/visit_mut.rs +++ b/crates/toml_edit/src/visit_mut.rs @@ -72,7 +72,7 @@ //! table = { apple = 4.5 } //! "#; //! -//! let mut document: Document = input.parse().unwrap(); +//! let mut document: DocumentMut = input.parse().unwrap(); //! let mut visitor = FloatToString; //! visitor.visit_document_mut(&mut document); //! @@ -90,7 +90,7 @@ //! [on GitHub](https://github.com/toml-rs/toml/blob/main/crates/toml_edit/examples/visit.rs). use crate::{ - Array, ArrayOfTables, Datetime, Document, Formatted, InlineTable, Item, KeyMut, Table, + Array, ArrayOfTables, Datetime, DocumentMut, Formatted, InlineTable, Item, KeyMut, Table, TableLike, Value, }; @@ -98,7 +98,7 @@ use crate::{ /// /// See the [module documentation](self) for details. pub trait VisitMut { - fn visit_document_mut(&mut self, node: &mut Document) { + fn visit_document_mut(&mut self, node: &mut DocumentMut) { visit_document_mut(self, node); } @@ -157,7 +157,7 @@ pub trait VisitMut { } } -pub fn visit_document_mut(v: &mut V, node: &mut Document) +pub fn visit_document_mut(v: &mut V, node: &mut DocumentMut) where V: VisitMut + ?Sized, { diff --git a/crates/toml_edit/tests/decoder.rs b/crates/toml_edit/tests/decoder.rs index 7306d455..6ccce135 100644 --- a/crates/toml_edit/tests/decoder.rs +++ b/crates/toml_edit/tests/decoder.rs @@ -9,14 +9,14 @@ impl toml_test_harness::Decoder for Decoder { fn decode(&self, data: &[u8]) -> Result { let data = std::str::from_utf8(data).map_err(toml_test_harness::Error::new)?; let document = data - .parse::() + .parse::() .map_err(toml_test_harness::Error::new)?; document_to_decoded(&document) } } fn document_to_decoded( - value: &toml_edit::Document, + value: &toml_edit::DocumentMut, ) -> Result { table_to_decoded(value) } diff --git a/crates/toml_edit/tests/encoder.rs b/crates/toml_edit/tests/encoder.rs index 808a20c4..79f7f6c2 100644 --- a/crates/toml_edit/tests/encoder.rs +++ b/crates/toml_edit/tests/encoder.rs @@ -14,9 +14,9 @@ impl toml_test_harness::Encoder for Encoder { fn decoded_to_document( decoded: &toml_test_harness::Decoded, -) -> Result { +) -> Result { let item = root_from_decoded(decoded)?; - let mut doc = toml_edit::Document::new(); + let mut doc = toml_edit::DocumentMut::new(); *doc = item; Ok(doc) } diff --git a/crates/toml_edit/tests/invalid.rs b/crates/toml_edit/tests/invalid.rs index 9fff2358..211786aa 100644 --- a/crates/toml_edit/tests/invalid.rs +++ b/crates/toml_edit/tests/invalid.rs @@ -1,4 +1,4 @@ -use toml_edit::Document; +use toml_edit::DocumentMut; fn main() { let args = libtest_mimic::Arguments::from_args(); @@ -21,6 +21,6 @@ fn main() { fn run_case(input: &[u8]) -> Result<(), String> { let raw = std::str::from_utf8(input).map_err(|e| e.to_string())?; - let _ = raw.parse::().map_err(|e| e.to_string())?; + let _ = raw.parse::().map_err(|e| e.to_string())?; Ok(()) } diff --git a/crates/toml_edit/tests/testsuite/convert.rs b/crates/toml_edit/tests/testsuite/convert.rs index 98f93979..ea09c5d7 100644 --- a/crates/toml_edit/tests/testsuite/convert.rs +++ b/crates/toml_edit/tests/testsuite/convert.rs @@ -1,6 +1,6 @@ use snapbox::assert_eq; -use toml_edit::{Document, Item, Value}; +use toml_edit::{DocumentMut, Item, Value}; #[test] fn table_into_inline() { @@ -13,7 +13,7 @@ inline = { "1" = 1, "2" = 2 } [table.child] other = "world" "#; - let mut doc = toml.parse::().unwrap(); + let mut doc = toml.parse::().unwrap(); doc.get_mut("table").unwrap().make_value(); @@ -28,7 +28,7 @@ other = "world" fn inline_table_to_table() { let toml = r#"table = { string = "value", array = [1, 2, 3], inline = { "1" = 1, "2" = 2 }, child = { other = "world" } } "#; - let mut doc = toml.parse::().unwrap(); + let mut doc = toml.parse::().unwrap(); let t = doc.remove("table").unwrap(); let t = match t { @@ -67,7 +67,7 @@ inline = { "1" = 1, "2" = 2 } [table.child] other = "world" "#; - let mut doc = toml.parse::().unwrap(); + let mut doc = toml.parse::().unwrap(); doc.get_mut("table").unwrap().make_value(); diff --git a/crates/toml_edit/tests/testsuite/datetime.rs b/crates/toml_edit/tests/testsuite/datetime.rs index 541f8ea1..7974ee17 100644 --- a/crates/toml_edit/tests/testsuite/datetime.rs +++ b/crates/toml_edit/tests/testsuite/datetime.rs @@ -1,6 +1,6 @@ macro_rules! bad { ($toml:expr, $msg:expr) => { - match $toml.parse::() { + match $toml.parse::() { Ok(s) => panic!("parsed to: {:#?}", s), Err(e) => snapbox::assert_eq($msg, e.to_string()), } @@ -11,7 +11,7 @@ macro_rules! bad { fn times() { fn dogood(s: &str, serialized: &str) { let to_parse = format!("foo = {}", s); - let document = to_parse.parse::().unwrap(); + let document = to_parse.parse::().unwrap(); assert_eq!( document["foo"].as_datetime().unwrap().to_string(), serialized diff --git a/crates/toml_edit/tests/testsuite/edit.rs b/crates/toml_edit/tests/testsuite/edit.rs index 94c20d41..d185bac9 100644 --- a/crates/toml_edit/tests/testsuite/edit.rs +++ b/crates/toml_edit/tests/testsuite/edit.rs @@ -2,7 +2,7 @@ use std::fmt; use std::iter::FromIterator; use snapbox::assert_eq; -use toml_edit::{array, table, value, Document, Item, Key, Table, Value}; +use toml_edit::{array, table, value, DocumentMut, Item, Key, Table, Value}; macro_rules! parse_key { ($s:expr) => {{ @@ -33,11 +33,11 @@ impl<'a> fmt::Debug for PrettyString<'a> { } struct Test { - doc: Document, + doc: DocumentMut, } fn given(input: &str) -> Test { - let doc = input.parse::(); + let doc = input.parse::(); assert!(doc.is_ok()); Test { doc: doc.unwrap() } } @@ -125,7 +125,7 @@ fn test_inserted_leaf_table_goes_after_last_sibling() { fn test_inserting_tables_from_different_parsed_docs() { given("[a]") .running(|root| { - let other = "[b]".parse::().unwrap(); + let other = "[b]".parse::().unwrap(); root["b"] = other["b"].clone(); }) .produces_display("[a]\n[b]\n"); diff --git a/crates/toml_edit/tests/testsuite/float.rs b/crates/toml_edit/tests/testsuite/float.rs index 34e792ed..20da23f9 100644 --- a/crates/toml_edit/tests/testsuite/float.rs +++ b/crates/toml_edit/tests/testsuite/float.rs @@ -1,4 +1,4 @@ -use toml_edit::Document; +use toml_edit::DocumentMut; macro_rules! float_inf_tests { ($ty:ty) => {{ @@ -18,7 +18,7 @@ macro_rules! float_inf_tests { sf8 = -0.0 "; - let document = document.parse::().unwrap(); + let document = document.parse::().unwrap(); let float = |k| document[k].as_float().unwrap(); assert!(float("sf1").is_infinite()); @@ -40,7 +40,7 @@ macro_rules! float_inf_tests { assert_eq!(float("sf8"), 0.0); assert!(float("sf8").is_sign_negative()); - let mut document = Document::new(); + let mut document = DocumentMut::new(); document["sf4"] = toml_edit::value(f64::NAN.copysign(1.0)); document["sf6"] = toml_edit::value(f64::NAN.copysign(-1.0)); assert_eq!( diff --git a/crates/toml_edit/tests/testsuite/invalid.rs b/crates/toml_edit/tests/testsuite/invalid.rs index cb13b4e7..5e7acca0 100644 --- a/crates/toml_edit/tests/testsuite/invalid.rs +++ b/crates/toml_edit/tests/testsuite/invalid.rs @@ -1,6 +1,6 @@ #[test] fn incomplete_inline_table_issue_296() { - let err = "native = {".parse::().unwrap_err(); + let err = "native = {".parse::().unwrap_err(); snapbox::assert_eq( r#"TOML parse error at line 1, column 11 | @@ -15,7 +15,7 @@ expected `}` #[test] fn bare_value_disallowed_issue_293() { - let err = "value=zzz".parse::().unwrap_err(); + let err = "value=zzz".parse::().unwrap_err(); snapbox::assert_eq( r#"TOML parse error at line 1, column 7 | @@ -30,7 +30,7 @@ expected `"`, `'` #[test] fn bare_value_in_array_disallowed_issue_293() { - let err = "value=[zzz]".parse::().unwrap_err(); + let err = "value=[zzz]".parse::().unwrap_err(); snapbox::assert_eq( r#"TOML parse error at line 1, column 8 | @@ -55,7 +55,7 @@ libc = \"0.2\" [dependencies] rand = \"0.3.14\" " - .parse::() + .parse::() .unwrap_err(); snapbox::assert_eq( r#"TOML parse error at line 8, column 1 @@ -79,7 +79,7 @@ TOML parse error at line 1, column 6 | ^ expected newline, `#` "; - let err = toml_input.parse::().unwrap_err(); + let err = toml_input.parse::().unwrap_err(); snapbox::assert_eq(expected_err, err.to_string()); let toml_input = "a = 1__1"; @@ -91,7 +91,7 @@ TOML parse error at line 1, column 7 invalid integer expected digit "; - let err = toml_input.parse::().unwrap_err(); + let err = toml_input.parse::().unwrap_err(); snapbox::assert_eq(expected_err, err.to_string()); let toml_input = "a = 1_"; @@ -103,7 +103,7 @@ TOML parse error at line 1, column 7 invalid integer expected digit "; - let err = toml_input.parse::().unwrap_err(); + let err = toml_input.parse::().unwrap_err(); snapbox::assert_eq(expected_err, err.to_string()); let toml_input = "''"; @@ -114,7 +114,7 @@ TOML parse error at line 1, column 3 | ^ expected `.`, `=` "; - let err = toml_input.parse::().unwrap_err(); + let err = toml_input.parse::().unwrap_err(); snapbox::assert_eq(expected_err, err.to_string()); let toml_input = "a = 9e99999"; @@ -125,7 +125,7 @@ TOML parse error at line 1, column 5 | ^ invalid floating-point number "; - let err = toml_input.parse::().unwrap_err(); + let err = toml_input.parse::().unwrap_err(); snapbox::assert_eq(expected_err, err.to_string()); let toml_input = "a = \"\u{7f}\""; @@ -136,7 +136,7 @@ TOML parse error at line 1, column 6 | ^ invalid basic string "; - let err = toml_input.parse::().unwrap_err(); + let err = toml_input.parse::().unwrap_err(); snapbox::assert_eq(expected_err, err.to_string()); let toml_input = "a = '\u{7f}'"; @@ -147,7 +147,7 @@ TOML parse error at line 1, column 6 | ^ invalid literal string "; - let err = toml_input.parse::().unwrap_err(); + let err = toml_input.parse::().unwrap_err(); snapbox::assert_eq(expected_err, err.to_string()); let toml_input = "a = -0x1"; @@ -158,7 +158,7 @@ TOML parse error at line 1, column 7 | ^ expected newline, `#` "; - let err = toml_input.parse::().unwrap_err(); + let err = toml_input.parse::().unwrap_err(); snapbox::assert_eq(expected_err, err.to_string()); let toml_input = "a = 0x-1"; @@ -169,7 +169,7 @@ TOML parse error at line 1, column 7 | ^ invalid hexadecimal integer "; - let err = toml_input.parse::().unwrap_err(); + let err = toml_input.parse::().unwrap_err(); snapbox::assert_eq(expected_err, err.to_string()); // Dotted keys. @@ -183,7 +183,7 @@ TOML parse error at line 2, column 10 | ^ duplicate key `b` in document root "; - let err = toml_input.parse::().unwrap_err(); + let err = toml_input.parse::().unwrap_err(); snapbox::assert_eq(expected_err, err.to_string()); let toml_input = "a = 1 @@ -195,7 +195,7 @@ TOML parse error at line 2, column 10 | ^ dotted key `a` attempted to extend non-table type (integer) "; - let err = toml_input.parse::().unwrap_err(); + let err = toml_input.parse::().unwrap_err(); snapbox::assert_eq(expected_err, err.to_string()); let toml_input = "a = {k1 = 1, k1.name = \"joe\"}"; @@ -206,6 +206,6 @@ TOML parse error at line 1, column 6 | ^ dotted key `k1` attempted to extend non-table type (integer) "; - let err = toml_input.parse::().unwrap_err(); + let err = toml_input.parse::().unwrap_err(); snapbox::assert_eq(expected_err, err.to_string()); } diff --git a/crates/toml_edit/tests/testsuite/parse.rs b/crates/toml_edit/tests/testsuite/parse.rs index f22b61d8..56851091 100644 --- a/crates/toml_edit/tests/testsuite/parse.rs +++ b/crates/toml_edit/tests/testsuite/parse.rs @@ -1,5 +1,5 @@ use snapbox::assert_eq; -use toml_edit::{Document, Key, Value}; +use toml_edit::{DocumentMut, Key, Value}; macro_rules! parse { ($s:expr, $ty:ty) => {{ @@ -87,7 +87,7 @@ fn test_key_unification() { [a.'b'.c.e] [a.'b'.c.d] "#; - let doc = toml.parse::(); + let doc = toml.parse::(); assert!(doc.is_ok()); let doc = doc.unwrap(); @@ -96,7 +96,7 @@ fn test_key_unification() { macro_rules! bad { ($toml:expr, $msg:expr) => { - match $toml.parse::() { + match $toml.parse::() { Ok(s) => panic!("parsed to: {:#?}", s), Err(e) => snapbox::assert_eq($msg, e.to_string()), } @@ -123,7 +123,7 @@ fn crlf() { contents are never required to be entirely resident in memory all at once.\r\n\ \"\"\"\ " - .parse::() + .parse::() .unwrap(); } @@ -163,7 +163,7 @@ All other whitespace is preserved. ''' "# - .parse::() + .parse::() .unwrap(); assert_eq!(table["bar"].as_str(), Some("\0")); assert_eq!(table["key1"].as_str(), Some("One\nTwo")); @@ -216,7 +216,7 @@ fn tables_in_arrays() { [foo.bar] #... "# - .parse::() + .parse::() .unwrap(); table["foo"][0]["bar"].as_table().unwrap(); table["foo"][1]["bar"].as_table().unwrap(); @@ -226,7 +226,7 @@ fn tables_in_arrays() { fn empty_table() { let table = r#" [foo]"# - .parse::() + .parse::() .unwrap(); table["foo"].as_table().unwrap(); } @@ -239,7 +239,7 @@ metadata.msrv = "1.65.0" [package.metadata.release.pre-release-replacements] "#; - let document = input.parse::().unwrap(); + let document = input.parse::().unwrap(); let actual = document.to_string(); assert_eq(input, actual); } @@ -266,7 +266,7 @@ name = "banana" [[fruit.variety]] name = "plantain" "# - .parse::() + .parse::() .unwrap(); assert_eq!(table["fruit"][0]["name"].as_str(), Some("apple")); assert_eq!(table["fruit"][0]["physical"]["color"].as_str(), Some("red")); @@ -373,13 +373,13 @@ invalid basic string #[test] fn blank_literal_string() { - let table = "foo = ''".parse::().unwrap(); + let table = "foo = ''".parse::().unwrap(); assert_eq!(table["foo"].as_str(), Some("")); } #[test] fn many_blank() { - let table = "foo = \"\"\"\n\n\n\"\"\"".parse::().unwrap(); + let table = "foo = \"\"\"\n\n\n\"\"\"".parse::().unwrap(); assert_eq!(table["foo"].as_str(), Some("\n\n")); } @@ -389,7 +389,7 @@ fn literal_eats_crlf() { foo = \"\"\"\\\r\n\"\"\" bar = \"\"\"\\\r\n \r\n \r\n a\"\"\" " - .parse::() + .parse::() .unwrap(); assert_eq!(table["foo"].as_str(), Some("")); assert_eq!(table["bar"].as_str(), Some("a")); @@ -586,7 +586,7 @@ fn floats() { ($actual:expr, $expected:expr) => {{ let f = format!("foo = {}", $actual); println!("{}", f); - let a = f.parse::().unwrap(); + let a = f.parse::().unwrap(); assert_eq!(a["foo"].as_float().unwrap(), $expected); }}; } @@ -621,7 +621,7 @@ fn bare_key_names() { \"character encoding\" = \"value\" 'ʎǝʞ' = \"value\" " - .parse::() + .parse::() .unwrap(); let _ = &a["foo"]; let _ = &a["-"]; @@ -901,7 +901,7 @@ fn table_names() { ['a.a'] ['\"\"'] " - .parse::() + .parse::() .unwrap(); println!("{:?}", a); let _ = &a["a"]["b"]; @@ -927,11 +927,11 @@ expected `.`, `=` #[test] fn inline_tables() { - "a = {}".parse::().unwrap(); - "a = {b=1}".parse::().unwrap(); - "a = { b = 1 }".parse::().unwrap(); - "a = {a=1,b=2}".parse::().unwrap(); - "a = {a=1,b=2,c={}}".parse::().unwrap(); + "a = {}".parse::().unwrap(); + "a = {b=1}".parse::().unwrap(); + "a = { b = 1 }".parse::().unwrap(); + "a = {a=1,b=2}".parse::().unwrap(); + "a = {a=1,b=2,c={}}".parse::().unwrap(); bad!( "a = {a=1,}", @@ -988,9 +988,9 @@ expected `}` " ); - "a = {a=[\n]}".parse::().unwrap(); - "a = {\"a\"=[\n]}".parse::().unwrap(); - "a = [\n{},\n{},\n]".parse::().unwrap(); + "a = {a=[\n]}".parse::().unwrap(); + "a = {\"a\"=[\n]}".parse::().unwrap(); + "a = [\n{},\n{},\n]".parse::().unwrap(); } #[test] @@ -998,7 +998,7 @@ fn number_underscores() { macro_rules! t { ($actual:expr, $expected:expr) => {{ let f = format!("foo = {}", $actual); - let table = f.parse::().unwrap(); + let table = f.parse::().unwrap(); assert_eq!(table["foo"].as_integer().unwrap(), $expected); }}; } @@ -1118,7 +1118,7 @@ invalid literal string #[test] fn empty_string() { assert_eq!( - "foo = \"\"".parse::().unwrap()["foo"] + "foo = \"\"".parse::().unwrap()["foo"] .as_str() .unwrap(), "" @@ -1127,10 +1127,10 @@ fn empty_string() { #[test] fn booleans() { - let table = "foo = true".parse::().unwrap(); + let table = "foo = true".parse::().unwrap(); assert_eq!(table["foo"].as_bool(), Some(true)); - let table = "foo = false".parse::().unwrap(); + let table = "foo = false".parse::().unwrap(); assert_eq!(table["foo"].as_bool(), Some(false)); bad!( @@ -1327,7 +1327,7 @@ fn datetimes() { macro_rules! t { ($actual:expr) => {{ let f = format!("foo = {}", $actual); - let toml = f.parse::().expect(&format!("failed: {}", f)); + let toml = f.parse::().expect(&format!("failed: {}", f)); assert_eq!(toml["foo"].as_datetime().unwrap().to_string(), $actual); }}; } @@ -1471,14 +1471,14 @@ fn dont_use_dotted_key_prefix_on_table_fuzz_57049() { p.a=4 [p.o] "#; - let document = input.parse::().unwrap(); + let document = input.parse::().unwrap(); let actual = document.to_string(); assert_eq(input, actual); } #[test] fn despan_keys() { - let mut doc = r#"aaaaaa = 1"#.parse::().unwrap(); + let mut doc = r#"aaaaaa = 1"#.parse::().unwrap(); let key = "bbb".parse::().unwrap(); let table = doc.as_table_mut(); table.insert_formatted( @@ -1503,7 +1503,7 @@ clippy.exhaustive_enums = "warn" "###; let expected = input; - let manifest: toml_edit::Document = input.parse().unwrap(); + let manifest: toml_edit::DocumentMut = input.parse().unwrap(); let actual = manifest.to_string(); assert_eq(expected, actual); diff --git a/crates/toml_edit/tests/testsuite/stackoverflow.rs b/crates/toml_edit/tests/testsuite/stackoverflow.rs index de4c7226..2e6d2466 100644 --- a/crates/toml_edit/tests/testsuite/stackoverflow.rs +++ b/crates/toml_edit/tests/testsuite/stackoverflow.rs @@ -4,7 +4,7 @@ fn array_recursion_limit() { let depths = [(1, true), (20, true), (300, false)]; for (depth, is_ok) in depths { let input = format!("x={}{}", &"[".repeat(depth), &"]".repeat(depth)); - let document = input.parse::(); + let document = input.parse::(); assert_eq!(document.is_ok(), is_ok, "depth: {}", depth); } } @@ -15,7 +15,7 @@ fn inline_table_recursion_limit() { let depths = [(1, true), (20, true), (300, false)]; for (depth, is_ok) in depths { let input = format!("x={}true{}", &"{ x = ".repeat(depth), &"}".repeat(depth)); - let document = input.parse::(); + let document = input.parse::(); assert_eq!(document.is_ok(), is_ok, "depth: {}", depth); } } @@ -26,7 +26,7 @@ fn table_key_recursion_limit() { let depths = [(1, true), (20, true), (300, false)]; for (depth, is_ok) in depths { let input = format!("[x{}]", &".x".repeat(depth)); - let document = input.parse::(); + let document = input.parse::(); assert_eq!(document.is_ok(), is_ok, "depth: {}", depth); } } @@ -37,7 +37,7 @@ fn dotted_key_recursion_limit() { let depths = [(1, true), (20, true), (300, false)]; for (depth, is_ok) in depths { let input = format!("x{} = true", &".x".repeat(depth)); - let document = input.parse::(); + let document = input.parse::(); assert_eq!(document.is_ok(), is_ok, "depth: {}", depth); } } @@ -48,7 +48,7 @@ fn inline_dotted_key_recursion_limit() { let depths = [(1, true), (20, true), (300, false)]; for (depth, is_ok) in depths { let input = format!("x = {{ x{} = true }}", &".x".repeat(depth)); - let document = input.parse::(); + let document = input.parse::(); assert_eq!(document.is_ok(), is_ok, "depth: {}", depth); } }