Struct jrsonnet_gcmodule::RawCc
source · pub struct RawCc<T: ?Sized, O: AbstractObjectSpace>(/* private fields */);
Expand description
Low-level type for Cc<T>
.
Implementations§
source§impl<T: Trace> RawCc<T, ObjectSpace>
impl<T: Trace> RawCc<T, ObjectSpace>
sourcepub fn new(value: T) -> Cc<T>
pub fn new(value: T) -> Cc<T>
Constructs a new Cc<T>
in a thread-local storage.
To collect cycles, use collect_thread_cycles
.
source§impl<T: Trace + Clone> RawCc<T, ObjectSpace>
impl<T: Trace + Clone> RawCc<T, ObjectSpace>
sourcepub fn update_with(&mut self, update_func: impl FnMut(&mut T))
pub fn update_with(&mut self, update_func: impl FnMut(&mut T))
Update the value T
in a copy-on-write way.
If the ref count is 1, the value is updated in-place.
Otherwise a new Cc<T>
will be created.
source§impl<T: ?Sized, O: AbstractObjectSpace> RawCc<T, O>
impl<T: ?Sized, O: AbstractObjectSpace> RawCc<T, O>
sourcepub fn strong_count(&self) -> usize
pub fn strong_count(&self) -> usize
Gets the reference count not considering weak references.
source§impl<T: ?Sized, O: AbstractObjectSpace> RawCc<T, O>
impl<T: ?Sized, O: AbstractObjectSpace> RawCc<T, O>
sourcepub fn trace(&self, tracer: &mut Tracer<'_>)
pub fn trace(&self, tracer: &mut Tracer<'_>)
trace
without T: Trace
bound.
Useful for structures with Cc<T>
fields where T
does not implement
Trace
. For example, struct S(Cc<Box<dyn MyTrait>>)
. To implement
Trace
for S
, it can use Cc::trace(&self.0, tracer)
.
sourcepub fn weak_count(&self) -> usize
pub fn weak_count(&self) -> usize
Get the weak (non-owning) reference count.
source§impl<T: ?Sized> RawCc<T, ThreadedObjectSpace>
impl<T: ?Sized> RawCc<T, ThreadedObjectSpace>
sourcepub fn borrow(&self) -> ThreadedCcRef<'_, T>
pub fn borrow(&self) -> ThreadedCcRef<'_, T>
Immutably borrows the wrapped value.
The borrow lasts until the returned value exits scope.
Trait Implementations§
source§impl<T: Ord + ?Sized> Ord for RawCc<T, ObjectSpace>
impl<T: Ord + ?Sized> Ord for RawCc<T, ObjectSpace>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<T: PartialEq + ?Sized> PartialEq for RawCc<T, ObjectSpace>
impl<T: PartialEq + ?Sized> PartialEq for RawCc<T, ObjectSpace>
source§impl<T: PartialOrd + ?Sized> PartialOrd for RawCc<T, ObjectSpace>
impl<T: PartialOrd + ?Sized> PartialOrd for RawCc<T, ObjectSpace>
source§fn le(&self, other: &RawCc<T, O>) -> bool
fn le(&self, other: &RawCc<T, O>) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl<T: Eq + ?Sized> Eq for RawCc<T, ObjectSpace>
impl<T: UnwindSafe + ?Sized, O: AbstractObjectSpace> UnwindSafe for RawCc<T, O>
Auto Trait Implementations§
impl<T, O> Freeze for RawCc<T, O>where
T: ?Sized,
impl<T, O> !RefUnwindSafe for RawCc<T, O>
impl<T, O> !Send for RawCc<T, O>
impl<T, O> !Sync for RawCc<T, O>
impl<T, O> Unpin for RawCc<T, O>where
T: ?Sized,
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