Add Freeze::clone

This commit is contained in:
John Kåre Alsaker 2023-09-08 14:14:57 +02:00
parent f49382c050
commit c83eba9251
2 changed files with 12 additions and 8 deletions

View file

@ -45,6 +45,16 @@ impl<T> FreezeLock<T> {
}
}
/// Clones the inner value along with the frozen state.
#[inline]
pub fn clone(&self) -> Self
where
T: Clone,
{
let lock = self.read();
Self::with(lock.clone(), self.is_frozen())
}
#[inline]
pub fn is_frozen(&self) -> bool {
self.frozen.load(Ordering::Acquire)