diff options
Diffstat (limited to 'src')
123 files changed, 3783 insertions, 13341 deletions
diff --git a/src/data/arena.rs b/src/data/arena.rs index fcec017..9d057b8 100644 --- a/src/data/arena.rs +++ b/src/data/arena.rs @@ -3,6 +3,7 @@ //! See https://github.com/fitzgen/generational-arena/blob/master/src/lib.rs. //! This has been modified to have a fully deterministic deserialization (including for the order of //! Index attribution after a deserialization of the arena. +use parry::partitioning::IndexedData; use std::cmp; use std::iter::{self, Extend, FromIterator, FusedIterator}; use std::mem; @@ -51,6 +52,16 @@ pub struct Index { generation: u64, } +impl IndexedData for Index { + fn default() -> Self { + Self::from_raw_parts(crate::INVALID_USIZE, crate::INVALID_U64) + } + + fn index(&self) -> usize { + self.into_raw_parts().0 + } +} + impl Index { /// Create a new `Index` from its raw parts. /// diff --git a/src/data/hashmap.rs b/src/data/hashmap.rs deleted file mode 100644 index d2ea980..0000000 --- a/src/data/hashmap.rs +++ /dev/null @@ -1,137 +0,0 @@ -//! A hash-map that behaves deterministically when the -//! `enhanced-determinism` feature is enabled. - -#[cfg(all(feature = "enhanced-determinism", feature = "serde-serialize"))] -use indexmap::IndexMap as StdHashMap; -#[cfg(all(not(feature = "enhanced-determinism"), feature = "serde-serialize"))] -use std::collections::HashMap as StdHashMap; - -/// Serializes only the capacity of a hash-map instead of its actual content. -#[cfg(feature = "serde-serialize")] -pub fn serialize_hashmap_capacity<S: serde::Serializer, K, V, H: std::hash::BuildHasher>( - map: &StdHashMap<K, V, H>, - s: S, -) -> Result<S::Ok, S::Error> { - s.serialize_u64(map.capacity() as u64) -} - -/// Creates a new hash-map with its capacity deserialized from `d`. -#[cfg(feature = "serde-serialize")] -pub fn deserialize_hashmap_capacity< - 'de, - D: serde::Deserializer<'de>, - K, - V, - H: std::hash::BuildHasher + Default, ->( - d: D, -) -> Result<StdHashMap<K, V, H>, D::Error> { - struct CapacityVisitor; - impl<'de> serde::de::Visitor<'de> for CapacityVisitor { - |
