diff --git a/crates/toml_edit/src/item.rs b/crates/toml_edit/src/item.rs index 48a1a356..2025fd91 100644 --- a/crates/toml_edit/src/item.rs +++ b/crates/toml_edit/src/item.rs @@ -7,7 +7,7 @@ use crate::table::TableLike; use crate::{Array, InlineTable, Table, Value}; /// Type representing either a value, a table, an array of tables, or none. -#[derive(Debug, Clone)] +#[derive(Debug)] pub enum Item { /// Type representing none. None, @@ -316,6 +316,18 @@ impl Item { } } +impl Clone for Item { + #[inline(never)] + fn clone(&self) -> Self { + match self { + Item::None => Item::None, + Item::Value(v) => Item::Value(v.clone()), + Item::Table(v) => Item::Table(v.clone()), + Item::ArrayOfTables(v) => Item::ArrayOfTables(v.clone()), + } + } +} + impl Default for Item { fn default() -> Self { Item::None diff --git a/crates/toml_edit/src/key.rs b/crates/toml_edit/src/key.rs index b7038c36..c1ee1655 100644 --- a/crates/toml_edit/src/key.rs +++ b/crates/toml_edit/src/key.rs @@ -29,7 +29,7 @@ use crate::InternalString; /// For details see [toml spec](https://github.com/toml-lang/toml/#keyvalue-pair). /// /// To parse a key use `FromStr` trait implementation: `"string".parse::()`. -#[derive(Debug, Clone)] +#[derive(Debug)] pub struct Key { key: InternalString, pub(crate) repr: Option, @@ -142,6 +142,17 @@ impl Key { } } +impl Clone for Key { + #[inline(never)] + fn clone(&self) -> Self { + Self { + key: self.key.clone(), + repr: self.repr.clone(), + decor: self.decor.clone(), + } + } +} + impl std::ops::Deref for Key { type Target = str; diff --git a/crates/toml_edit/src/parser/numbers.rs b/crates/toml_edit/src/parser/numbers.rs index 3e6eb5dd..6e4757f0 100644 --- a/crates/toml_edit/src/parser/numbers.rs +++ b/crates/toml_edit/src/parser/numbers.rs @@ -211,7 +211,10 @@ pub(crate) fn float(input: &mut Input<'_>) -> PResult { } pub(crate) fn float_<'i>(input: &mut Input<'i>) -> PResult<&'i str> { - (dec_int, alt((exp, (frac, opt(exp)).map(|_| "")))) + ( + dec_int, + alt((exp.void(), (frac.void(), opt(exp.void())).void())), + ) .recognize() .map(|b: &[u8]| unsafe { from_utf8_unchecked(