Struct jrsonnet_gcmodule::RawCc
source · [−]pub struct RawCc<T: ?Sized, O: AbstractObjectSpace>(_);
Expand description
Low-level type for Cc<T>
.
Implementations
sourceimpl<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
.
sourceimpl<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.
sourceimpl<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.
sourceimpl<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.
sourceimpl<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
sourceimpl<T: Ord + ?Sized> Ord for RawCc<T, O>
impl<T: Ord + ?Sized> Ord for RawCc<T, O>
sourceimpl<T: PartialOrd + ?Sized> PartialOrd<RawCc<T, ObjectSpace>> for RawCc<T, O>
impl<T: PartialOrd + ?Sized> PartialOrd<RawCc<T, ObjectSpace>> for RawCc<T, O>
sourcefn partial_cmp(&self, other: &RawCc<T, O>) -> Option<Ordering>
fn partial_cmp(&self, other: &RawCc<T, O>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
sourcefn lt(&self, other: &RawCc<T, O>) -> bool
fn lt(&self, other: &RawCc<T, O>) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
sourcefn 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 more
impl<T: Eq + ?Sized> Eq for RawCc<T, O>
impl<T: UnwindSafe + ?Sized, O: AbstractObjectSpace> UnwindSafe for RawCc<T, O>
Auto Trait Implementations
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: ?Sized, O> Unpin for RawCc<T, O>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more