diff --git a/crates/toml/src/map.rs b/crates/toml/src/map.rs index f7d5c38f..71cf7449 100644 --- a/crates/toml/src/map.rs +++ b/crates/toml/src/map.rs @@ -135,7 +135,14 @@ impl Map { String: Borrow, Q: Ord + Eq + Hash + ?Sized, { - self.map.remove(key) + #[cfg(not(feature = "preserve_order"))] + { + self.map.remove(key) + } + #[cfg(feature = "preserve_order")] + { + self.map.shift_remove(key) + } } /// Retains only the elements specified by the `keep` predicate. @@ -501,7 +508,14 @@ impl<'a> OccupiedEntry<'a> { /// Takes the value of the entry out of the map, and returns it. #[inline] pub fn remove(self) -> Value { - self.occupied.remove() + #[cfg(not(feature = "preserve_order"))] + { + self.occupied.remove() + } + #[cfg(feature = "preserve_order")] + { + self.occupied.shift_remove() + } } } diff --git a/crates/toml_edit/src/ser/map.rs b/crates/toml_edit/src/ser/map.rs index f1924982..e23a0caf 100644 --- a/crates/toml_edit/src/ser/map.rs +++ b/crates/toml_edit/src/ser/map.rs @@ -1,6 +1,7 @@ use super::{Error, KeySerializer, SerializeValueArray, ValueSerializer}; #[doc(hidden)] +#[allow(clippy::large_enum_variant)] pub enum SerializeMap { Datetime(SerializeDatetime), Table(SerializeInlineTable),