pub struct Alc<T: Clone>(/* private fields */);
Expand description
Alc is a thread-safe LazyClone wrapper, to provide lazy cloning for any data
that doesn’t implement LazyClone
and need thread-safety
If you’re able to implement LazyClone for the data that you need, do it, if not, use this wrapper
Implementations§
Source§impl<T: Clone> Alc<T>
impl<T: Clone> Alc<T>
Sourcepub fn read_mut(&mut self) -> &mut T
pub fn read_mut(&mut self) -> &mut T
Ensures that the lazily cloned value is mutable and returns a mutable reference to it
Sourcepub fn write(&mut self, value: T)
pub fn write(&mut self, value: T)
Replaces the cloned value by another
Does not affect any value lazily cloned from this value
Sourcepub fn take(&self) -> T
pub fn take(&self) -> T
Does an actual clone of the contained value
This clone may be expensive
Trait Implementations§
Source§impl<T: Clone> BorrowMut<T> for Alc<T>
impl<T: Clone> BorrowMut<T> for Alc<T>
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T: Clone> LazyClone for Alc<T>
impl<T: Clone> LazyClone for Alc<T>
Source§fn lazy(&self) -> Self
fn lazy(&self) -> Self
The O(1) lazy-clone method.
Useful for cloning data that doesn’t necessarily need to be mutated.
Source§fn eager(&self) -> Self
fn eager(&self) -> Self
A non-lazy cloning method. Useful for cloning data that is known to modified
Source§fn is_mutable(&self) -> bool
fn is_mutable(&self) -> bool
Checks if the structure can be mutated with no side effects
Auto Trait Implementations§
impl<T> Freeze for Alc<T>
impl<T> RefUnwindSafe for Alc<T>where
T: RefUnwindSafe,
impl<T> Send for Alc<T>
impl<T> Sync for Alc<T>
impl<T> Unpin for Alc<T>
impl<T> UnwindSafe for Alc<T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more