diff options
author | Melody Horn <melody@boringcactus.com> | 2021-03-21 14:10:24 -0600 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2021-03-21 14:10:24 -0600 |
commit | 7bbbfd046324363c8db1fb15d39aeb02fe7331b5 (patch) | |
tree | a416bb991c23e083d0b5816dfc8b00cd1aceda78 /src | |
parent | b1417006df376e6c406bff43740dd11aa7ef744e (diff) | |
download | milf-rs-main.tar.gz milf-rs-main.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/datetime.rs | 16 | ||||
-rw-r--r-- | src/de.rs | 38 | ||||
-rw-r--r-- | src/lib.rs | 34 | ||||
-rw-r--r-- | src/macros.rs | 166 | ||||
-rw-r--r-- | src/map.rs | 16 | ||||
-rw-r--r-- | src/ser.rs | 38 | ||||
-rw-r--r-- | src/spanned.rs | 14 | ||||
-rw-r--r-- | src/value.rs | 44 |
8 files changed, 183 insertions, 183 deletions
diff --git a/src/datetime.rs b/src/datetime.rs index 1f68bfd..2445c48 100644 --- a/src/datetime.rs +++ b/src/datetime.rs @@ -4,22 +4,22 @@ use std::str::{self, FromStr}; use serde::{de, ser}; -/// A parsed TOML datetime value +/// A parsed MILF datetime value /// /// This structure is intended to represent the datetime primitive type that can -/// be encoded into TOML documents. This type is a parsed version that contains +/// be encoded into MILF documents. This type is a parsed version that contains /// all metadata internally. /// /// Currently this type is intentionally conservative and only supports /// `to_string` as an accessor. Over time though it's intended that it'll grow /// more support! /// -/// Note that if you're using `Deserialize` to deserialize a TOML document, you +/// Note that if you're using `Deserialize` to deserialize a MILF document, you /// can use this as a placeholder for where you're expecting a datetime to be /// specified. /// /// Also note though that while this type implements `Serialize` and -/// `Deserialize` it's only recommended to use this type with the TOML format, +/// `Deserialize` it's only recommended to use this type with the MILF format, /// otherwise encoded in other formats it may look a little odd. #[derive(PartialEq, Clone)] pub struct Datetime { @@ -38,10 +38,10 @@ pub struct DatetimeParseError { // to a special valid in the serde data model. Namely one with these special // fields/struct names. // -// In general the TOML encoder/decoder will catch this and not literally emit +// In general the MILF encoder/decoder will catch this and not literally emit // these strings but rather emit datetimes as they're intended. -pub const FIELD: &str = "$__toml_private_datetime"; -pub const NAME: &str = "$__toml_private_Datetime"; +pub const FIELD: &str = "$__milf_private_datetime"; +pub const NAME: &str = "$__milf_private_Datetime"; #[derive(PartialEq, Clone)] struct Date { @@ -329,7 +329,7 @@ impl<'de> de::Deserialize<'de> for Datetime { type Value = Datetime; fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - formatter.write_str("a TOML datetime") + formatter.write_str("a MILF datetime") } fn visit_map<V>(self, mut visitor: V) -> Result<Datetime, V::Error> @@ -1,6 +1,6 @@ -//! Deserializing TOML into Rust structures. +//! Deserializing MILF into Rust structures. //! -//! This module contains all the Serde support for deserializing TOML documents +//! This module contains all the Serde support for deserializing MILF documents //! into Rust structures. Note that some top-level functions here are also //! provided at the top of the crate. @@ -22,13 +22,13 @@ use crate::datetime; use crate::spanned; use crate::tokens::{Error as TokenError, Span, Token, Tokenizer}; -/// Type Alias for a TOML Table pair +/// Type Alias for a MILF Table pair type TablePair<'a> = ((Span, Cow<'a, str>), Value<'a>); /// Deserializes a byte slice into a type. /// /// This function will attempt to interpret `bytes` as UTF-8 data and then -/// deserialize `T` from the TOML document provided. +/// deserialize `T` from the MILF document provided. pub fn from_slice<'de, T>(bytes: &'de [u8]) -> Result<T, Error> where T: de::Deserialize<'de>, @@ -41,7 +41,7 @@ where /// Deserializes a string into a type. /// -/// This function will attempt to interpret `s` as a TOML document and +/// This function will attempt to interpret `s` as a MILF document and /// deserialize `T` from the document. /// /// # Examples @@ -61,14 +61,14 @@ where /// } /// /// fn main() { -/// let config: Config = toml::from_str(r#" -/// title = 'TOML Example' +/// let config: Config = milf::from_str(r#" +/// title = 'MILF Example' /// /// [owner] /// name = 'Lisa' /// "#).unwrap(); /// -/// assert_eq!(config.title, "TOML Example"); +/// assert_eq!(config.title, "MILF Example"); /// assert_eq!(config.owner.name, "Lisa"); /// } /// ``` @@ -198,7 +198,7 @@ enum ErrorKind { __Nonexhaustive, } -/// Deserialization implementation for TOML. +/// Deserialization implementation for MILF. pub struct Deserializer<'a> { require_newline_after_table: bool, allow_duplciate_after_longer_table: bool, @@ -231,7 +231,7 @@ impl<'de, 'b> de::Deserializer<'de> for &'b mut Deserializer<'de> { de: self, }); res.map_err(|mut err| { - // Errors originating from this library (toml), have an offset + // Errors originating from this library (milf), have an offset // attached to them already. Other errors, like those originating // from serde (like "missing field") or from a custom deserializer, // do not have offsets on them. Here, we do a best guess at their @@ -444,7 +444,7 @@ impl<'de, 'b> de::MapAccess<'de> for MapVisitor<'de, 'b> { self.cur = pos; // Test to see if we're duplicating our parent's table, and if so - // then this is an error in the toml format + // then this is an error in the milf format if self.cur_parent != pos { if headers_equal( &self.tables[self.cur_parent].header, @@ -647,7 +647,7 @@ impl<'de, 'b> de::Deserializer<'de> for MapVisitor<'de, 'b> { && !(self.array && !self.values.peek().is_none()) { // TODO we can't actually emit spans here for the *entire* table/array - // due to the format that toml uses. Setting the start and end to 0 is + // due to the format that milf uses. Setting the start and end to 0 is // *detectable* (and no reasonable span would look like that), // it would be better to expose this in the API via proper // ADTs like Option<T>. @@ -1283,22 +1283,22 @@ impl<'a> Deserializer<'a> { Ok(()) } - /// Historical versions of toml-rs accidentally allowed a newline after a - /// table definition, but the TOML spec requires a newline after a table + /// Historical versions of milf-rs accidentally allowed a newline after a + /// table definition, but the MILF spec requires a newline after a table /// definition header. /// /// This option can be set to `false` (the default is `true`) to emulate - /// this behavior for backwards compatibility with older toml-rs versions. + /// this behavior for backwards compatibility with older milf-rs versions. pub fn set_require_newline_after_table(&mut self, require: bool) { self.require_newline_after_table = require; } - /// Historical versions of toml-rs accidentally allowed a duplicate table + /// Historical versions of milf-rs accidentally allowed a duplicate table /// header after a longer table header was previously defined. This is - /// invalid according to the TOML spec, however. + /// invalid according to the MILF spec, however. /// /// This option can be set to `true` (the default is `false`) to emulate - /// this behavior for backwards compatibility with older toml-rs versions. + /// this behavior for backwards compatibility with older milf-rs versions. pub fn set_allow_duplicate_after_longer_table(&mut self, allow: bool) { self.allow_duplciate_after_longer_table = allow; } @@ -2148,7 +2148,7 @@ impl fmt::Display for Error { )?, ErrorKind::UnquotedString => write!( f, - "invalid TOML value, did you mean to use a quoted string?" + "invalid MILF value, did you mean to use a quoted string?" )?, ErrorKind::__Nonexhaustive => panic!(), } @@ -1,14 +1,14 @@ -//! A [TOML]-parsing library +//! A [My INI-Like Format (MILF)]-parsing library //! -//! This library implements a [TOML] v0.5.0 compatible parser, +//! This library implements a [MILF] v0.5.0 compatible parser, //! primarily supporting the [`serde`] library for encoding/decoding //! various types in Rust. //! -//! TOML itself is a simple, ergonomic, and readable configuration format: +//! MILF itself is a simple, ergonomic, and readable configuration format: //! //! ```toml //! [package] -//! name = "toml" +//! name = "milf" //! version = "0.4.2" //! authors = ["Alex Crichton <alex@alexcrichton.com>"] //! @@ -16,12 +16,12 @@ //! serde = "1.0" //! ``` //! -//! The TOML format tends to be relatively common throughout the Rust community +//! The MILF format tends to be relatively common throughout the Rust community //! for configuration, notably being used by [Cargo], Rust's package manager. //! -//! ## TOML values +//! ## MILF values //! -//! A value in TOML is represented with the [`Value`] enum in this crate: +//! A value in MILF is represented with the [`Value`] enum in this crate: //! //! ```rust,ignore //! pub enum Value { @@ -35,16 +35,16 @@ //! } //! ``` //! -//! TOML is similar to JSON with the notable addition of a [`Datetime`] -//! type. In general, TOML and JSON are interchangeable in terms of +//! MILF is similar to JSON with the notable addition of a [`Datetime`] +//! type. In general, MILF and JSON are interchangeable in terms of //! formats. //! -//! ## Parsing TOML +//! ## Parsing MILF //! -//! The easiest way to parse a TOML document is via the [`Value`] type: +//! The easiest way to parse a MILF document is via the [`Value`] type: //! //! ```rust -//! use toml::Value; +//! use milf::Value; //! //! let value = "foo = 'bar'".parse::<Value>().unwrap(); //! @@ -74,7 +74,7 @@ //! use the [`Deserializer`], [`Serializer`], or [`Value`] type itself to act as //! a deserializer/serializer for arbitrary types. //! -//! An example of deserializing with TOML is: +//! An example of deserializing with MILF is: //! //! ```rust //! use serde_derive::Deserialize; @@ -93,7 +93,7 @@ //! } //! //! fn main() { -//! let config: Config = toml::from_str(r#" +//! let config: Config = milf::from_str(r#" //! ip = '127.0.0.1' //! //! [keys] @@ -136,15 +136,15 @@ //! }, //! }; //! -//! let toml = toml::to_string(&config).unwrap(); +//! let milf = milf::to_string(&config).unwrap(); //! } //! ``` //! -//! [TOML]: https://github.com/toml-lang/toml +//! [MILF]: https://github.com/toml-lang/toml //! [Cargo]: https://crates.io/ //! [`serde`]: https://serde.rs/ -#![doc(html_root_url = "https://docs.rs/toml/0.5")] +#![doc(html_root_url = "https://docs.rs/milf/0.5")] #![deny(missing_docs)] #![warn(rust_2018_idioms)] // Makes rustc abort compilation if there are any unsafe blocks in the crate. diff --git a/src/macros.rs b/src/macros.rs index 0731afe..ed719ae 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -2,15 +2,15 @@ pub use serde::de::{Deserialize, IntoDeserializer}; use crate::value::{Array, Table, Value}; -/// Construct a [`toml::Value`] from TOML syntax. +/// Construct a [`milf::Value`] from MILF syntax. /// -/// [`toml::Value`]: value/enum.Value.html +/// [`milf::Value`]: value/enum.Value.html /// /// ```rust /// fn main() { -/// let cargo_toml = toml::toml! { +/// let cargo_milf = milf::milf! { /// [package] -/// name = "toml" +/// name = "milf" /// version = "0.4.5" /// authors = ["Alex Crichton <alex@alexcrichton.com>"] /// @@ -25,20 +25,20 @@ use crate::value::{Array, Table, Value}; /// serde_json = "1.0" /// }; /// -/// println!("{:#?}", cargo_toml); +/// println!("{:#?}", cargo_milf); /// } /// ``` #[macro_export] -macro_rules! toml { - ($($toml:tt)+) => {{ +macro_rules! milf { + ($($milf:tt)+) => {{ let table = $crate::value::Table::new(); let mut root = $crate::Value::Table(table); - $crate::toml_internal!(@toplevel root [] $($toml)+); + $crate::milf_internal!(@toplevel root [] $($milf)+); root }}; } -// TT-muncher to parse TOML syntax into a toml::Value. +// TT-muncher to parse MILF syntax into a milf::Value. // // @toplevel -- Parse tokens outside of an inline table or inline array. In // this state, `[table headers]` and `[[array headers]]` are @@ -55,13 +55,13 @@ macro_rules! toml { // primitive or inline table or inline array. // // @table -- Parse the contents of an inline table, returning them as a -// toml::Value::Table. +// milf::Value::Table. // // @tabledatetime -- Helper to parse a Datetime from string and insert it // into a table, continuing in the @table state. // // @array -- Parse the contents of an inline array, returning them as a -// toml::Value::Array. +// milf::Value::Array. // // @arraydatetime -- Helper to parse a Datetime from string and push it into // an array, continuing in the @array state. @@ -72,105 +72,105 @@ macro_rules! toml { // #[macro_export] #[doc(hidden)] -macro_rules! toml_internal { +macro_rules! milf_internal { // Base case, no elements remaining. (@toplevel $root:ident [$($path:tt)*]) => {}; // Parse negative number `key = -value`. (@toplevel $root:ident [$($path:tt)*] $($($k:tt)-+).+ = - $v:tt $($rest:tt)*) => { - $crate::toml_internal!(@toplevel $root [$($path)*] $($($k)-+).+ = (-$v) $($rest)*); + $crate::milf_internal!(@toplevel $root [$($path)*] $($($k)-+).+ = (-$v) $($rest)*); }; // Parse positive number `key = +value`. (@toplevel $root:ident [$($path:tt)*] $($($k:tt)-+).+ = + $v:tt $($rest:tt)*) => { - $crate::toml_internal!(@toplevel $root [$($path)*] $($($k)-+).+ = ($v) $($rest)*); + $crate::milf_internal!(@toplevel $root [$($path)*] $($($k)-+).+ = ($v) $($rest)*); }; // Parse offset datetime `key = 1979-05-27T00:32:00.999999-07:00`. (@toplevel $root:ident [$($path:tt)*] $($($k:tt)-+).+ = $yr:tt - $mo:tt - $dhr:tt : $min:tt : $sec:tt . $frac:tt - $tzh:tt : $tzm:tt $($rest:tt)*) => { - $crate::toml_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($yr - $mo - $dhr : $min : $sec . $frac - $tzh : $tzm) $($rest)*); + $crate::milf_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($yr - $mo - $dhr : $min : $sec . $frac - $tzh : $tzm) $($rest)*); }; // Space instead of T. (@toplevel $root:ident [$($path:tt)*] $($($k:tt)-+).+ = $yr:tt - $mo:tt - $day:tt $hr:tt : $min:tt : $sec:tt . $frac:tt - $tzh:tt : $tzm:tt $($rest:tt)*) => { - $crate::toml_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($yr - $mo - $day T $hr : $min : $sec . $frac - $tzh : $tzm) $($rest)*); + $crate::milf_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($yr - $mo - $day T $hr : $min : $sec . $frac - $tzh : $tzm) $($rest)*); }; // Parse offset datetime `key = 1979-05-27T00:32:00-07:00`. (@toplevel $root:ident [$($path:tt)*] $($($k:tt)-+).+ = $yr:tt - $mo:tt - $dhr:tt : $min:tt : $sec:tt - $tzh:tt : $tzm:tt $($rest:tt)*) => { - $crate::toml_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($yr - $mo - $dhr : $min : $sec - $tzh : $tzm) $($rest)*); + $crate::milf_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($yr - $mo - $dhr : $min : $sec - $tzh : $tzm) $($rest)*); }; // Space instead of T. (@toplevel $root:ident [$($path:tt)*] $($($k:tt)-+).+ = $yr:tt - $mo:tt - $day:tt $hr:tt : $min:tt : $sec:tt - $tzh:tt : $tzm:tt $($rest:tt)*) => { - $crate::toml_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($yr - $mo - $day T $hr : $min : $sec - $tzh : $tzm) $($rest)*); + $crate::milf_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($yr - $mo - $day T $hr : $min : $sec - $tzh : $tzm) $($rest)*); }; // Parse local datetime `key = 1979-05-27T00:32:00.999999`. (@toplevel $root:ident [$($path:tt)*] $($($k:tt)-+).+ = $yr:tt - $mo:tt - $dhr:tt : $min:tt : $sec:tt . $frac:tt $($rest:tt)*) => { - $crate::toml_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($yr - $mo - $dhr : $min : $sec . $frac) $($rest)*); + $crate::milf_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($yr - $mo - $dhr : $min : $sec . $frac) $($rest)*); }; // Space instead of T. (@toplevel $root:ident [$($path:tt)*] $($($k:tt)-+).+ = $yr:tt - $mo:tt - $day:tt $hr:tt : $min:tt : $sec:tt . $frac:tt $($rest:tt)*) => { - $crate::toml_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($yr - $mo - $day T $hr : $min : $sec . $frac) $($rest)*); + $crate::milf_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($yr - $mo - $day T $hr : $min : $sec . $frac) $($rest)*); }; // Parse offset datetime `key = 1979-05-27T07:32:00Z` and local datetime `key = 1979-05-27T07:32:00`. (@toplevel $root:ident [$($path:tt)*] $($($k:tt)-+).+ = $yr:tt - $mo:tt - $dhr:tt : $min:tt : $sec:tt $($rest:tt)*) => { - $crate::toml_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($yr - $mo - $dhr : $min : $sec) $($rest)*); + $crate::milf_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($yr - $mo - $dhr : $min : $sec) $($rest)*); }; // Space instead of T. (@toplevel $root:ident [$($path:tt)*] $($($k:tt)-+).+ = $yr:tt - $mo:tt - $day:tt $hr:tt : $min:tt : $sec:tt $($rest:tt)*) => { - $crate::toml_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($yr - $mo - $day T $hr : $min : $sec) $($rest)*); + $crate::milf_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($yr - $mo - $day T $hr : $min : $sec) $($rest)*); }; // Parse local date `key = 1979-05-27`. (@toplevel $root:ident [$($path:tt)*] $($($k:tt)-+).+ = $yr:tt - $mo:tt - $day:tt $($rest:tt)*) => { - $crate::toml_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($yr - $mo - $day) $($rest)*); + $crate::milf_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($yr - $mo - $day) $($rest)*); }; // Parse local time `key = 00:32:00.999999`. (@toplevel $root:ident [$($path:tt)*] $($($k:tt)-+).+ = $hr:tt : $min:tt : $sec:tt . $frac:tt $($rest:tt)*) => { - $crate::toml_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($hr : $min : $sec . $frac) $($rest)*); + $crate::milf_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($hr : $min : $sec . $frac) $($rest)*); }; // Parse local time `key = 07:32:00`. (@toplevel $root:ident [$($path:tt)*] $($($k:tt)-+).+ = $hr:tt : $min:tt : $sec:tt $($rest:tt)*) => { - $crate::toml_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($hr : $min : $sec) $($rest)*); + $crate::milf_internal!(@topleveldatetime $root [$($path)*] $($($k)-+).+ = ($hr : $min : $sec) $($rest)*); }; // Parse any other `key = value` including string, inline array, inline // table, number, and boolean. (@toplevel $root:ident [$($path:tt)*] $($($k:tt)-+).+ = $v:tt $($rest:tt)*) => {{ - $crate::macros::insert_toml( + $crate::macros::insert_milf( &mut $root, - &[$($path)* $(&concat!($("-", $crate::toml_internal!(@path $k),)+)[1..], )+], - $crate::toml_internal!(@value $v)); - $crate::toml_internal!(@toplevel $root [$($path)*] $($rest)*); + &[$($path)* $(&concat!($("-", $crate::milf_internal!(@path $k),)+)[1..], )+], + $crate::milf_internal!(@value $v)); + $crate::milf_internal!(@toplevel $root [$($path)*] $($rest)*); }}; // Parse array header `[[bin]]`. (@toplevel $root:ident $oldpath:tt [[$($($path:tt)-+).+]] $($rest:tt)*) => { - $crate::macros::push_toml( + $crate::macros::push_milf( &mut $root, - &[$(&concat!($("-", $crate::toml_internal!(@path $path),)+)[1..],)+]); - $crate::toml_internal!(@toplevel $root [$(&concat!($("-", $crate::toml_internal!(@path $path),)+)[1..],)+] $($rest)*); + &[$(&concat!($("-", $crate::milf_internal!(@path $path),)+)[1..],)+]); + $crate::milf_internal!(@toplevel $root [$(&concat!($("-", $crate::milf_internal!(@path $path),)+)[1..],)+] $($rest)*); }; // Parse table header `[patch.crates-io]`. (@toplevel $root:ident $oldpath:tt [$($($path:tt)-+).+] $($rest:tt)*) => { - $crate::macros::insert_toml( + $crate::macros::insert_milf( &mut $root, - &[$(&concat!($("-", $crate::toml_internal!(@path $path),)+)[1..],)+], + &[$(&concat!($("-", $crate::milf_internal!(@path $path),)+)[1..],)+], $crate::Value::Table($crate::value::Table::new())); - $crate::toml_internal!(@toplevel $root [$(&concat!($("-", $crate::toml_internal!(@path $path),)+)[1..],)+] $($rest)*); + $crate::milf_internal!(@toplevel $root [$(&concat!($("-", $crate::milf_internal!(@path $path),)+)[1..],)+] $($rest)*); }; // Parse datetime from string and insert into table. (@topleveldatetime $root:ident [$($path:tt)*] $($($k:tt)-+).+ = ($($datetime:tt)+) $($rest:tt)*) => { - $crate::macros::insert_toml( + $crate::macros::insert_milf( &mut $root, - &[$($path)* $(&concat!($("-", $crate::toml_internal!(@path $k),)+)[1..], )+], + &[$($path)* $(&concat!($("-", $crate::milf_internal!(@path $k),)+)[1..], )+], $crate::Value::Datetime(concat!($(stringify!($datetime)),+).parse().unwrap())); - $crate::toml_internal!(@toplevel $root [$($path)*] $($rest)*); + $crate::milf_internal!(@toplevel $root [$($path)*] $($rest)*); }; // Turn a path segment into a string. @@ -187,14 +187,14 @@ macro_rules! toml_internal { // Construct a Value from an inline table. (@value { $($inline:tt)* }) => {{ let mut table = $crate::Value::Table($crate::value::Table::new()); - $crate::toml_internal!(@trailingcomma (@table table) $($inline)*); + $crate::milf_internal!(@trailingcomma (@table table) $($inline)*); table }}; // Construct a Value from an inline array. (@value [ $($inline:tt)* ]) => {{ let mut array = $crate::value::Array::new(); - $crate::toml_internal!(@trailingcomma (@array array) $($inline)*); + $crate::milf_internal!(@trailingcomma (@array array) $($inline)*); $crate::Value::Array(array) }}; @@ -234,81 +234,81 @@ macro_rules! toml_internal { // Parse negative number `key = -value`. (@table $root:ident $($($k:tt)-+).+ = - $v:tt , $($rest:tt)*) => { - $crate::toml_internal!(@table $root $($($k)-+).+ = (-$v) , $($rest)*); + $crate::milf_internal!(@table $root $($($k)-+).+ = (-$v) , $($rest)*); }; // Parse positive number `key = +value`. (@table $root:ident $($($k:tt)-+).+ = + $v:tt , $($rest:tt)*) => { - $crate::toml_internal!(@table $root $($($k)-+).+ = ($v) , $($rest)*); + $crate::milf_internal!(@table $root $($($k)-+).+ = ($v) , $($rest)*); }; // Parse offset datetime `key = 1979-05-27T00:32:00.999999-07:00`. (@table $root:ident $($($k:tt)-+).+ = $yr:tt - $mo:tt - $dhr:tt : $min:tt : $sec:tt . $frac:tt - $tzh:tt : $tzm:tt , $($rest:tt)*) => { - $crate::toml_internal!(@tabledatetime $root $($($k)-+).+ = ($yr - $mo - $dhr : $min : $sec . $frac - $tzh : $tzm) $($rest)*); + $crate::milf_internal!(@tabledatetime $root $($($k)-+).+ = ($yr - $mo - $dhr : $min : $sec . $frac - $tzh : $tzm) $($rest)*); }; // Space instead of T. (@table $root:ident $($($k:tt)-+).+ = $yr:tt - $mo:tt - $day:tt $hr:tt : $min:tt : $sec:tt . $frac:tt - $tzh:tt : $tzm:tt , $($rest:tt)*) => { - $crate::toml_internal!(@tabledatetime $root $($($k)-+).+ = ($yr - $mo - $day T $hr : $min : $sec . $frac - $tzh : $tzm) $($rest)*); + $crate::milf_internal!(@tabledatetime $root $($($k)-+).+ = ($yr - $mo - $day T $hr : $min : $sec . $frac - $tzh : $tzm) $($rest)*); }; // Parse offset datetime `key = 1979-05-27T00:32:00-07:00`. (@table $root:ident $($($k:tt)-+).+ = $yr:tt - $mo:tt - $dhr:tt : $min:tt : $sec:tt - $tzh:tt : $tzm:tt , $($rest:tt)*) => { - $crate::toml_internal!(@tabledatetime $root $($($k)-+).+ = ($yr - $mo - $dhr : $min : $sec - $tzh : $tzm) $($rest)*); + $crate::milf_internal!(@tabledatetime $root $($($k)-+).+ = ($yr - $mo - $dhr : $min : $sec - $tzh : $tzm) $($rest)*); }; // Space instead of T. (@table $root:ident $($($k:tt)-+).+ = $yr:tt - $mo:tt - $day:tt $hr:tt : $min:tt : $sec:tt - $tzh:tt : $tzm:tt , $($rest:tt)*) => { - $crate::toml_internal!(@tabledatetime $root $($($k)-+).+ = ($yr - $mo - $day T $hr : $min : $sec - $tzh : $tzm) $($rest)*); + $crate::milf_internal!(@tabledatetime $root $($($k)-+).+ = ($yr - $mo - $day T $hr : $min : $sec - $tzh : $tzm) $($rest)*); }; // Parse local datetime `key = 1979-05-27T00:32:00.999999`. (@table $root:ident $($($k:tt)-+).+ = $yr:tt - $mo:tt - $dhr:tt : $min:tt : $sec:tt . $frac:tt , $($rest:tt)*) => { - $crate::toml_internal!(@tabledatetime $root $($($k)-+).+ = ($yr - $mo - $dhr : $min : $sec . $frac) $($rest)*); + $crate::milf_internal!(@tabledatetime $root $($($k)-+).+ = ($yr - $mo - $dhr : $min : $sec . $frac) $($rest)*); }; // Space instead of T. (@table $root:ident $($($k:tt)-+).+ = $yr:tt - $mo:tt - $day:tt $hr:tt : $min:tt : $sec:tt . $frac:tt , $($rest:tt)*) => { - $crate::toml_internal!(@tabledatetime $root $($($k)-+).+ = ($yr - $mo - $day T $hr : $min : $sec . $frac) $($rest)*); + $crate::milf_internal!(@tabledatetime $root $($($k)-+).+ = ($yr - $mo - $day T $hr : $min : $sec . $frac) $($rest)*); }; // Parse offset datetime `key = 1979-05-27T07:32:00Z` and local datetime `key = 1979-05-27T07:32:00`. (@table $root:ident $($($k:tt)-+).+ = $yr:tt - $mo:tt - $dhr:tt : $min:tt : $sec:tt , $($rest:tt)*) => { - $crate::toml_internal!(@tabledatetime $root $($($k)-+).+ = ($yr - $mo - $dhr : $min : $sec) $($rest)*); + $crate::milf_internal!(@tabledatetime $root $($($k)-+).+ = ($yr - $mo - $dhr : $min : $sec) $($rest)*); }; // Space instead of T. (@table $root:ident $($($k:tt)-+).+ = $yr:tt - $mo:tt - $day:tt $hr:tt : $min:tt : $sec:tt , $($rest:tt)*) => { - $crate::toml_internal!(@tabledatetime $root $($($k)-+).+ = ($yr - $mo - $day T $hr : $min : $sec) $($rest)*); + $crate::milf_internal!(@tabledatetime $root $($($k)-+).+ = ($yr - $mo - $day T $hr : $min : $sec) $($rest)*); }; // Parse local date `key = 1979-05-27`. (@table $root:ident $($($k:tt)-+).+ = $yr:tt - $mo:tt - $day:tt , $($rest:tt)*) => { - $crate::toml_internal!(@tabledatetime $root $($($k)-+).+ = ($yr - $mo - $day) $($rest)*); + $crate::milf_internal!(@tabledatetime $root $($($k)-+).+ = ($yr - $mo - $day) $($rest)*); }; // Parse local time `key = 00:32:00.999999`. (@table $root:ident $($($k:tt)-+).+ = $hr:tt : $min:tt : $sec:tt . $frac:tt , $($rest:tt)*) => { - $crate::toml_internal!(@tabledatetime $root $($($k)-+).+ = ($hr : $min : $sec . $frac) $($rest)*); + $crate::milf_internal!(@tabledatetime $root $($($k)-+).+ = ($hr : $min : $sec . $frac) $($rest)*); }; // Parse local time `key = 07:32:00`. (@table $root:ident $($($k:tt)-+).+ = $hr:tt : $min:tt : $sec:tt , $($rest:tt)*) => { - $crate::toml_internal!(@tabledatetime $root $($($k)-+).+ = ($hr : $min : $sec) $($rest)*); + $crate::milf_internal!(@tabledatetime $root $($($k)-+).+ = ($hr : $min : $sec) $($rest)*); }; // Parse any other type, probably string or boolean or number. (@table $root:ident $($($k:tt)-+).+ = $v:tt , $($rest:tt)*) => { - $crate::macros::insert_toml( + $crate::macros::insert_milf( &mut $root, - &[$(&concat!($("-", $crate::toml_internal!(@path $k),)+)[1..], )+], - $crate::toml_internal!(@value $v)); - $crate::toml_internal!(@table $root $($rest)*); + &[$(&concat!($("-", $crate::milf_internal!(@path $k),)+)[1..], )+], + $crate::milf_internal!(@value $v)); + $crate::milf_internal!(@table $root $($rest)*); }; // Parse a Datetime from string and continue in @table state. (@tabledatetime $root:ident $($($k:tt)-+).+ = ($($datetime:tt)*) $($rest:tt)*) => { - $crate::macros::insert_toml( + $crate::macros::insert_milf( &mut $root, - &[$(&concat!($("-", $crate::toml_internal!(@path $k),)+)[1..], )+], + &[$(&concat!($("-", $crate::milf_internal!(@path $k),)+)[1..], )+], $crate::Value::Datetime(concat!($(stringify!($datetime)),+).parse().unwrap())); - $crate::toml_internal!(@table $root $($rest)*); + $crate::milf_internal!(@table $root $($rest)*); }; // Base case of inline array. @@ -316,107 +316,107 @@ macro_rules! toml_internal { // Parse negative number `-value`. (@array $root:ident - $v:tt , $($rest:tt)*) => { - $crate::toml_internal!(@array $root (-$v) , $($rest)*); + $crate::milf_internal!(@array $root (-$v) , $($rest)*); }; // Parse positive number `+value`. (@array $root:ident + $v:tt , $($rest:tt)*) => { - $crate::toml_internal!(@array $root ($v) , $($rest)*); + $crate::milf_internal!(@array $root ($v) , $($rest)*); }; // Parse offset datetime `1979-05-27T00:32:00.999999-07:00`. (@array $root:ident $yr:tt - $mo:tt - $dhr:tt : $min:tt : $sec:tt . $frac:tt - $tzh:tt : $tzm:tt , $($rest:tt)*) => { - $crate::toml_internal!(@arraydatetime $root ($yr - $mo - $dhr : $min : $sec . $frac - $tzh : $tzm) $($rest)*); + $crate::milf_internal!(@arraydatetime $root ($yr - $mo - $dhr : $min : $sec . $frac - $tzh : $tzm) $($rest)*); }; // Space instead of T. (@array $root:ident $yr:tt - $mo:tt - $day:tt $hr:tt : $min:tt : $sec:tt . $frac:tt - $tzh:tt : $tzm:tt , $($rest:tt)*) => { - $crate::toml_internal!(@arraydatetime $root ($yr - $mo - $day T $hr : $min : $sec . $frac - $tzh : $tzm) $($rest)*); + $crate::milf_internal!(@arraydatetime $root ($yr - $mo - $day T $hr : $min : $sec . $frac - $tzh : $tzm) $($rest)*); }; // Parse offset datetime `1979-05-27T00:32:00-07:00`. (@array $root:ident $yr:tt - $mo:tt - $dhr:tt : $min:tt : $sec:tt - $tzh:tt : $tzm:tt , $($rest:tt)*) => { - $crate::toml_internal!(@arraydatetime $root ($yr - $mo - $dhr : $min : $sec - $tzh : $tzm) $($rest)*); + $crate::milf_internal!(@arraydatetime $root ($yr - $mo - $dhr : $min : $sec - $tzh : $tzm) $($rest)*); }; // Space instead of T. (@array $root:ident $yr:tt - $mo:tt - $day:tt $hr:tt : $min:tt : $sec:tt - $tzh:tt : $tzm:tt , $($rest:tt)*) => { - $crate::toml_internal!(@arraydatetime $root ($yr - $mo - $day T $hr : $min : $sec - $tzh : $tzm) $($rest)*); + $crate::milf_internal!(@arraydatetime $root ($yr - $mo - $day T $hr : $min : $sec - $tzh : $tzm) $($rest)*); }; // Parse local datetime `1979-05-27T00:32:00.999999`. (@array $root:ident $yr:tt - $mo:tt - $dhr:tt : $min:tt : $sec:tt . $frac:tt , $($rest:tt)*) => { - $crate::toml_internal!(@arraydatetime $root ($yr - $mo - $dhr : $min : $sec . $frac) $($rest)*); + $crate::milf_internal!(@arraydatetime $root ($yr - $mo - $dhr : $min : $sec . $frac) $($rest)*); }; // Space instead of T. (@array $root:ident $yr:tt - $mo:tt - $day:tt $hr:tt : $min:tt : $sec:tt . $frac:tt , $($rest:tt)*) => { - $crate::toml_internal!(@arraydatetime $root ($yr - $mo - $day T $hr : $min : $sec . $frac) $($rest)*); + $crate::milf_internal!(@arraydatetime $root ($yr - $mo - $day T $hr : $min : $sec . $frac) $($rest)*); }; // Parse offset datetime `1979-05-27T07:32:00Z` and local datetime `1979-05-27T07:32:00`. (@array $root:ident $yr:tt - $mo:tt - $dhr:tt : $min:tt : $sec:tt , $($rest:tt)*) => { - $crate::toml_internal!(@arraydatetime $root ($yr - $mo - $dhr : $min : $sec) $($rest)*); + $crate::milf_internal!(@arraydatetime $root ($yr - $mo - $dhr : $min : $sec) $($rest)*); }; // Space instead of T. (@array $root:ident $yr:tt - $mo:tt - $day:tt $hr:tt : $min:tt : $sec:tt , $($rest:tt)*) => { - $crate::toml_internal!(@arraydatetime $root ($yr - $mo - $day T $hr : $min : $sec) $($rest)*); + $crate::milf_internal!(@arraydatetime $root ($yr - $mo - $day T $hr : $min : $sec) $($rest)*); }; // Parse local date `1979-05-27`. (@array $root:ident $yr:tt - $mo:tt - $day:tt , $($rest:tt)*) => { - $crate::toml_internal!(@arraydatetime $root ($yr - $mo - $day) $($rest)*); + $crate::milf_internal!(@arraydatetime $root ($yr - $mo - $day) $($rest)*); }; // Parse local time `00:32:00.999999`. (@array $root:ident $hr:tt : $min:tt : $sec:tt . $frac:tt , $($rest:tt)*) => { - $crate::toml_internal!(@arraydatetime $root ($hr : $min : $sec . $frac) $($rest)*); + $crate::milf_internal!(@arraydatetime $root ($hr : $min : $sec . $frac) $($rest)*); }; // Parse local time `07:32:00`. (@array $root:ident $hr:tt : $min:tt : $sec:tt , $($rest:tt)*) => { - $crate::toml_internal!(@arraydatetime $root ($hr : $min : $sec) $($rest)*); + $crate::milf_internal!(@arraydatetime $root ($hr : $min : $sec) $($rest)*); }; // Parse any other type, probably string or boolean or number. (@array $root:ident $v:tt , $($rest:tt)*) => { - $root.push($crate::toml_internal!(@value $v)); - $crate::toml_internal!(@array $root $($rest)*); + $root.push($crate::milf_internal!(@value $v)); + $crate::milf_internal!(@array $root $($rest)*); }; // Parse a Datetime from string and continue in @array state. (@arraydatetime $root:ident ($($datetime:tt)*) $($rest:tt)*) => { $root.push($crate::Value::Datetime(concat!($(stringify!($datetime)),+).parse().unwrap())); - $crate::toml_internal!(@array $root $($rest)*); + $crate::milf_internal!(@array $root $($rest)*); }; // No trailing comma required if the tokens are empty. (@trailingcomma ($($args:tt)*)) => { - $crate::toml_internal!($($args)*); + $crate::milf_internal!($($args)*); }; // Tokens end with a trailing comma, do not append another one. (@trailingcomma ($($args:tt)*) ,) => { - $crate::toml_internal!($($args)* ,); + $crate::milf_internal!($($args)* ,); }; // Tokens end with something other than comma, append a trailing comma. (@trailingcomma ($($args:tt)*) $last:tt) => { - $crate::toml_internal!($($args)* $last ,); + $crate::milf_internal!($($args)* $last ,); }; // Not yet at the last token. (@trailingcomma ($($args:tt)*) $first:tt $($rest:tt)+) => { - $crate::toml_internal!(@trailingcomma ($($args)* $first) $($rest)+); + $crate::milf_internal!(@trailingcomma ($($args)* $first) $($rest)+); }; } // Called when parsing a `key = value` pair. // Inserts an entry into the table at the given path. -pub fn insert_toml(root: &mut Value, path: &[&str], value: Value) { +pub fn insert_milf(root: &mut Value, path: &[&str], value: Value) { *traverse(root, path) = value; } // Called when parsing an `[[array header]]`. // Pushes an empty table onto the array at the given path. -pub fn push_toml(root: &mut Value, path: &[&str]) { +pub fn push_milf(root: &mut Value, path: &[&str]) { let target = traverse(root, path); if !target.is_array() { *target = Value::Array(Array::new()); @@ -434,7 +434,7 @@ fn traverse<'a>(root: &'a mut Value, path: &[&str]) -> &'a mut Value { let cur1 = cur; let cur2; - // From the TOML spec: + // From the MILF spec: // // > Each double-bracketed sub-table will belong to the most recently // > defined table element above it. @@ -6,10 +6,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! A map of String to toml::Value. +//! A map of String to milf::Value. //! //! By default the map is backed by a [`BTreeMap`]. Enable the `preserve_order` -//! feature of toml-rs to use [`LinkedHashMap`] instead. +//! feature of milf-rs to use [`LinkedHashMap`] instead. //! //! [`BTreeMap`]: https://doc.rust-lang.org/std/collections/struct.BTreeMap.html //! [`LinkedHashMap`]: https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html @@ -28,7 +28,7 @@ use std::collections::{btree_map, BTreeMap}; #[cfg(feature = "preserve_order")] use indexmap::{self, IndexMap}; -/// Represents a TOML key/value type. +/// Represents a MILF key/value type. pub struct Map<K, V> { map: MapImpl<K, V>, } @@ -504,7 +504,7 @@ impl<'a> IntoIterator for &'a Map<String, Value> { } } -/// An iterator over a toml::Map's entries. +/// An iterator over a milf::Map's entries. pub struct Iter<'a> { iter: IterImpl<'a>, } @@ -529,7 +529,7 @@ impl<'a> IntoIterator for &'a mut Map<String, Value> { } } -/// A mutable iterator over a toml::Map's entries. +/// A mutable iterator over a milf::Map's entries. pub struct IterMut<'a> { iter: IterMutImpl<'a>, } @@ -554,7 +554,7 @@ impl IntoIterator for Map<String, Value> { } } -/// An owning iterator over a toml::Map's entries. +/// An owning iterator over a milf::Map's entries. pub struct IntoIter { iter: IntoIterImpl, } @@ -568,7 +568,7 @@ delegate_iterator!((IntoIter) => (String, Value)); ////////////////////////////////////////////////////////////////////////////// -/// An iterator over a toml::Map's keys. +/// An iterator over a milf::Map's keys. pub struct Keys<'a> { iter: KeysImpl<'a>, } @@ -582,7 +582,7 @@ delegate_iterator!((Keys<'a>) => &'a String); ////////////////////////////////////////////////////////////////////////////// -/// An iterator over a toml::Map's values. +/// An iterator over a milf::Map's values. pub struct Values<'a> { iter: ValuesImpl<'a>, } @@ -1,10 +1,10 @@ -//! Serializing Rust structures into TOML. +//! Serializing Rust structures into MILF. //! //! This module contains all the Serde support for serializing Rust structures -//! into TOML documents (as strings). Note that some top-level functions here +//! into MILF documents (as strings). Note that some top-level functions here //! are also provided at the top of the crate. //! -//! Note that the TOML format has a restriction that if a table itself contains +//! Note that the MILF format has a restriction that if a table itself contains //! tables, all keys with non-table values must be emitted first. This is //! typically easy to ensure happens when you're defining a `struct` as you can //! reorder the fields manually, but when working with maps (such as `BTreeMap` @@ -17,7 +17,7 @@ //! #[derive(Serialize)] //! struct Manifest { //! package: Package, -//! #[serde(serialize_with = "toml::ser::tables_last")] +//! #[serde(serialize_with = "milf::ser::tables_last")] //! dependencies: HashMap<String, Dependency>, //! } //! # type Package = String; @@ -34,7 +34,7 @@ use std::rc::Rc; use crate::datetime; use serde::ser; -/// Serialize the given data structure as a TOML byte vector. +/// Serialize the given data structure as a MILF byte vector. /// /// Serialization can fail if `T`'s implementation of `Serialize` decides to /// fail, if `T` contains a map with non-string keys, or if `T` attempts to @@ -46,7 +46,7 @@ where to_string(value).map(|e| e.into_bytes()) } -/// Serialize the given data structure as a String of TOML. +/// Serialize the given data structure as a String of MILF. /// /// Serialization can fail if `T`'s implementation of `Serialize` decides to /// fail, if `T` contains a map with non-string keys, or if `T` attempts to @@ -80,8 +80,8 @@ where /// }, /// }; /// -/// let toml = toml::to_string(&config).unwrap(); -/// println!("{}", toml) +/// let milf = milf::to_string(&config).unwrap(); +/// println!("{}", milf) /// } /// ``` pub fn to_string<T: ?Sized>(value: &T) -> Result<String, Error> @@ -93,7 +93,7 @@ where Ok(dst) } -/// Serialize the given data structure as a "pretty" String of TOML. +/// Serialize the given data structure as a "pretty" String of MILF. /// /// This is identical to `to_string` except the output string has a more /// "pretty" output. See `Serializer::pretty` for more details. @@ -112,11 +112,11 @@ pub enum Error { /// Indicates that a Rust type was requested to be serialized but it was not /// supported. /// - /// Currently the TOML format does not support serializing types such as + /// Currently the MILF format does not support serializing types such as /// enums, tuples and tuple structs. UnsupportedType, - /// The key of all TOML maps must be strings, but serialization was + /// The key of all MILF maps must be strings, but serialization was /// attempted where the key of a map was not a string. KeyNotString, @@ -128,7 +128,7 @@ pub enum Error { #[doc(hidden)] ArrayMixedType, - /// All values in a TOML table must be emitted before further tables are + /// All values in a MILF table must be emitted before further tables are /// emitted. If a value is emitted *after* a table then this error is /// generated. ValueAfterTable, @@ -186,10 +186,10 @@ struct Settings { string: Option<StringSettings>, } -/// Serialization implementation for TOML. +/// Serialization implementation for MILF. /// -/// This structure implements serialization support for TOML to serialize an -/// arbitrary type to TOML. Note that the TOML format does not support all +/// This structure implements serialization support for MILF to serialize an +/// arbitrary type to MILF. Note that the MILF format does not support all /// datatypes in Rust, such as enums, tuples, and tuple structs. These types /// will generate an error when serialized. /// @@ -244,7 +244,7 @@ pub enum SerializeTable<'a, 'b> { } impl<'a> Serializer<'a> { - /// Creates a new serializer which will emit TOML into the buffer provided. + /// Creates a new serializer which will emit MILF into the buffer provided. /// /// The serializer can then be used to serialize a type after which the data /// will be present in `dst`. @@ -1558,9 +1558,9 @@ enum Category { } /// Convenience function to serialize items in a map in an order valid with -/// TOML. +/// MILF. /// -/// TOML carries the restriction that keys in a table must be serialized last if +/// MILF carries the restriction that keys in a table must be serialized last if /// their value is a table itself. This isn't always easy to guarantee, so this /// helper can be used like so: /// @@ -1570,7 +1570,7 @@ enum Category { /// #[derive(Serialize)] /// struct Manifest { /// package: Package, -/// #[serde(serialize_with = "toml::ser::tables_last")] +/// #[serde(serialize_with = "milf::ser::tables_last")] /// dependencies: HashMap<String, Dependency>, /// } /// # type Package = String; diff --git a/src/spanned.rs b/src/spanned.rs index 9ee56ae..6c49eb9 100644 --- a/src/spanned.rs +++ b/src/spanned.rs @@ -4,16 +4,16 @@ use std::cmp::Ordering; use std::fmt; use std::hash::{Hash, Hasher}; -pub(crate) const NAME: &str = "$__toml_private_Spanned"; -pub(crate) const START: &str = "$__toml_private_start"; -pub(crate) const END: &str = "$__toml_private_end"; -pub(crate) const VALUE: &str = "$__toml_private_value"; +pub(crate) const NAME: &str = "$__milf_private_Spanned"; +pub(crate) const START: &str = "$__milf_private_start"; +pub(crate) const END: &str = "$__milf_private_end"; +pub(crate) const VALUE: &str = "$__milf_private_value"; /// A spanned value, indicating the range at which it is defined in the source. /// /// ``` /// use serde_derive::Deserialize; -/// use toml::Spanned; +/// use milf::Spanned; /// /// #[derive(Deserialize)] /// struct Value { @@ -23,7 +23,7 @@ pub(crate) const VALUE: &str = "$__toml_private_value"; /// fn main() { /// let t = "s = \"value\"\n"; /// -/// let u: Value = toml::from_str(t).unwrap(); +/// let u: Value = milf::from_str(t).unwrap(); /// /// assert_eq!(u.s.start(), 4); /// assert_eq!(u.s.end(), 11); @@ -122,7 +122,7 @@ where type Value = Spanned<T>; fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - formatter.write_str("a TOML spanned") + formatter.write_str("a MILF spanned") } fn visit_map<V>(self, mut visitor: V) -> Result<Spanned<T>, V::Error> diff --git a/src/value.rs b/src/value.rs index 38dfe1f..5bb0c55 100644 --- a/src/value.rs +++ b/src/value.rs @@ -1,4 +1,4 @@ -//! Definition of a TOML value +//! Definition of a MILF value use std::collections::{BTreeMap, HashMap}; use std::fmt; @@ -17,36 +17,36 @@ pub use crate::datetime::{Datetime, DatetimeParseError}; pub use crate::map::Map; -/// Representation of a TOML value. +/// Representation of a MILF value. #[derive(PartialEq, Clone, Debug)] pub enum Value { - /// Represents a TOML string + /// Represents a MILF string String(String), - /// Represents a TOML integer + /// Represents a MILF integer Integer(i64), - /// Represents a TOML float + /// Represents a MILF float Float(f64), - /// Represents a TOML boolean + /// Represents a MILF boolean Boolean(bool), - /// Represents a TOML datetime + /// Represents a MILF datetime Datetime(Datetime), - /// Represents a TOML array + /// Represents a MILF array Array(Array), - /// Represents a TOML table + /// Represents a MILF table Table(Table), } -/// Type representing a TOML array, payload of the `Value::Array` variant +/// Type representing a MILF array, payload of the `Value::Array` variant pub type Array = Vec<Value>; -/// Type representing a TOML table, payload of the `Value::Table` variant. +/// Type representing a MILF table, payload of the `Value::Table` variant. /// By default it is backed by a BTreeMap, enable the `preserve_order` feature /// to use a LinkedHashMap instead. pub type Table = Map<String, Value>; impl Value { - /// Convert a `T` into `toml::Value` which is an enum that can represent - /// any valid TOML data. + /// Convert a `T` into `milf::Value` which is an enum that can represent + /// any valid MILF data. /// /// This conversion can fail if `T`'s implementation of `Serialize` decides to /// fail, or if `T` contains a map with non-string keys. @@ -57,14 +57,14 @@ impl Value { value.serialize(Serializer) } - /// Interpret a `toml::Value` as an instance of type `T`. + /// Interpret a `milf::Value` as an instance of type `T`. /// /// This conversion can fail if the structure of the `Value` does not match the /// structure expected by `T`, for example if `T` is a struct type but the - /// `Value` contains something other than a TOML table. It can also fail if the + /// `Value` contains something other than a MILF table. It can also fail if the /// structure is correct but `T`'s implementation of `Deserialize` decides that /// something is wrong with the data, for example required struct fields are - /// missing from the TOML map or some number is too big to fit in the expected + /// missing from the MILF map or some number is too big to fit in the expected /// primitive type. pub fn try_into<'de, T>(self) -> Result<T, crate::de::Error> where @@ -73,7 +73,7 @@ impl Value { de::Deserialize::deserialize(self) } - /// Index into a TOML array or map. A string index can be used to access a + /// Index into a MILF array or map. A string index can be used to access a /// value in a map, and a usize index can be used to access an element of an /// array. /// @@ -85,7 +85,7 @@ impl Value { index.index(self) } - /// Mutably index into a TOML array or map. A string index can be used to + /// Mutably index into a MILF array or map. A string index can be used to /// access a value in a map, and a usize index can be used to access an /// element of an array. /// @@ -151,7 +151,7 @@ impl Value { /// Extracts the datetime value if it is a datetime. /// - /// Note that a parsed TOML value will only contain ISO 8601 dates. An + /// Note that a parsed MILF value will only contain ISO 8601 dates. An /// example date is: /// /// ```notrust @@ -302,13 +302,13 @@ impl_into_value!(Boolean: bool); impl_into_value!(Datetime: Datetime); impl_into_value!(Table: Table); -/// Types that can be used to index a `toml::Value` +/// Types that can be used to index a `milf::Value` /// /// Currently this is implemented for `usize` to index arrays and `str` to index /// tables. /// /// This trait is sealed and not intended for implementation outside of the -/// `toml` crate. +/// `milf` crate. pub trait Index: Sealed { #[doc(hidden)] fn index<'a>(&self, val: &'a Value) -> Option<&'a Value>; @@ -453,7 +453,7 @@ impl<'de> de::Deserialize<'de> for Value { type Value = Value; fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - formatter.write_str("any valid TOML value") + formatter.write_str("any valid MILF value") } fn visit_bool<E>(self, value: bool) -> Result<Value, E> { |