Rearrange persist module
This commit is contained in:
parent
8c25d8b092
commit
23f4fd6fc5
1 changed files with 15 additions and 15 deletions
|
@ -72,6 +72,21 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a, T> PersistentField<'a, T> for atomic_refcell::AtomicRefCell<T>
|
||||||
|
where
|
||||||
|
T: serde::Serialize + serde::Deserialize<'a> + Send + Sync,
|
||||||
|
{
|
||||||
|
fn set(&self, new_value: T) {
|
||||||
|
*self.borrow_mut() = new_value;
|
||||||
|
}
|
||||||
|
fn map<F, R>(&self, f: F) -> R
|
||||||
|
where
|
||||||
|
F: Fn(&T) -> R,
|
||||||
|
{
|
||||||
|
f(&self.borrow())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! impl_persistent_field_parking_lot_mutex {
|
macro_rules! impl_persistent_field_parking_lot_mutex {
|
||||||
($ty:ty) => {
|
($ty:ty) => {
|
||||||
impl<'a, T> PersistentField<'a, T> for $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<T>
|
|
||||||
where
|
|
||||||
T: serde::Serialize + serde::Deserialize<'a> + Send + Sync,
|
|
||||||
{
|
|
||||||
fn set(&self, new_value: T) {
|
|
||||||
*self.borrow_mut() = new_value;
|
|
||||||
}
|
|
||||||
fn map<F, R>(&self, f: F) -> R
|
|
||||||
where
|
|
||||||
F: Fn(&T) -> R,
|
|
||||||
{
|
|
||||||
f(&self.borrow())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl_persistent_field_parking_lot_mutex!(parking_lot::Mutex<T>);
|
impl_persistent_field_parking_lot_mutex!(parking_lot::Mutex<T>);
|
||||||
impl_persistent_field_parking_lot_mutex!(parking_lot::FairMutex<T>);
|
impl_persistent_field_parking_lot_mutex!(parking_lot::FairMutex<T>);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue