diff --git a/src/sync.rs b/src/sync.rs index c2e5701..d7b2945 100644 --- a/src/sync.rs +++ b/src/sync.rs @@ -828,6 +828,7 @@ fn test_non_lockfree() { /// Append-only threadsafe version of `std::collections::BTreeMap` where /// insertion does not require mutable access #[derive(Debug)] +#[cfg_attr(feature = "serde", derive(Serialize))] pub struct FrozenBTreeMap(RwLock>); impl FrozenBTreeMap { @@ -1008,3 +1009,11 @@ impl Default for FrozenBTreeMap { Self::new() } } + +#[cfg(feature = "serde")] +impl<'de> Deserialize<'de> for FrozenBTreeMap { + fn deserialize>(deserializer: D) -> Result { + let map = BTreeMap::::deserialize(deserializer)?; + Ok(map.into()) + } +}