Add Freeze::clone
This commit is contained in:
parent
f49382c050
commit
c83eba9251
@ -45,6 +45,16 @@ pub fn with(value: T, frozen: bool) -> Self {
|
||||
}
|
||||
}
|
||||
|
||||
/// 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)
|
||||
|
@ -1367,16 +1367,10 @@ fn clone(&self) -> Self {
|
||||
name: self.name.clone(),
|
||||
src: self.src.clone(),
|
||||
src_hash: self.src_hash,
|
||||
external_src: {
|
||||
let lock = self.external_src.read();
|
||||
FreezeLock::with(lock.clone(), self.external_src.is_frozen())
|
||||
},
|
||||
external_src: self.external_src.clone(),
|
||||
start_pos: self.start_pos,
|
||||
source_len: self.source_len,
|
||||
lines: {
|
||||
let lock = self.lines.read();
|
||||
FreezeLock::with(lock.clone(), self.lines.is_frozen())
|
||||
},
|
||||
lines: self.lines.clone(),
|
||||
multibyte_chars: self.multibyte_chars.clone(),
|
||||
non_narrow_chars: self.non_narrow_chars.clone(),
|
||||
normalized_pos: self.normalized_pos.clone(),
|
||||
|
Loading…
Reference in New Issue
Block a user