From 23f4fd6fc530995049cca0d80956bbf08aa74587 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Fri, 4 Nov 2022 17:22:49 +0100 Subject: [PATCH] Rearrange persist module --- src/params/persist.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/params/persist.rs b/src/params/persist.rs index 1363e7b4..54e48084 100644 --- a/src/params/persist.rs +++ b/src/params/persist.rs @@ -72,6 +72,21 @@ where } } +impl<'a, T> PersistentField<'a, T> for atomic_refcell::AtomicRefCell +where + T: serde::Serialize + serde::Deserialize<'a> + Send + Sync, +{ + fn set(&self, new_value: T) { + *self.borrow_mut() = new_value; + } + fn map(&self, f: F) -> R + where + F: Fn(&T) -> R, + { + f(&self.borrow()) + } +} + macro_rules! impl_persistent_field_parking_lot_mutex { ($ty:ty) => { impl<'a, T> PersistentField<'a, T> for $ty @@ -91,21 +106,6 @@ macro_rules! impl_persistent_field_parking_lot_mutex { }; } -impl<'a, T> PersistentField<'a, T> for atomic_refcell::AtomicRefCell -where - T: serde::Serialize + serde::Deserialize<'a> + Send + Sync, -{ - fn set(&self, new_value: T) { - *self.borrow_mut() = new_value; - } - fn map(&self, f: F) -> R - where - F: Fn(&T) -> R, - { - f(&self.borrow()) - } -} - impl_persistent_field_parking_lot_mutex!(parking_lot::Mutex); impl_persistent_field_parking_lot_mutex!(parking_lot::FairMutex);