pub struct Cc<T: ?Sized + Trace + 'static> { /* private fields */ }
Expand description
A thread-local cycle collected pointer.
See the module-level documentation for more details.
Implementations§
Source§impl<T: Trace> Cc<T>
impl<T: Trace> Cc<T>
Sourcepub fn new(t: T) -> Cc<T>
pub fn new(t: T) -> Cc<T>
Creates a new Cc
.
§Collection
This method may start a collection when the auto-collect
feature is enabled.
See the config
module documentation for more details.
§Panics
Panics if the automatically-stared collection panics.
Sourcepub fn try_unwrap(self) -> Result<T, Self>
pub fn try_unwrap(self) -> Result<T, Self>
Source§impl<T: ?Sized + Trace> Cc<T>
impl<T: ?Sized + Trace> Cc<T>
Sourcepub fn ptr_eq(this: &Cc<T>, other: &Cc<T>) -> bool
pub fn ptr_eq(this: &Cc<T>, other: &Cc<T>) -> bool
Returns true
if the two Cc
s point to the same allocation. This function ignores the metadata of dyn Trait
pointers.
Sourcepub fn strong_count(&self) -> u32
pub fn strong_count(&self) -> u32
Returns the number of Cc
s to the pointed allocation.
Sourcepub fn finalize_again(&mut self)
Available on crate feature finalization
only.
pub fn finalize_again(&mut self)
finalization
only.Makes the value in the managed allocation finalizable again.
§Panics
Panics if called during a collection.
Sourcepub fn already_finalized(&self) -> bool
Available on crate feature finalization
only.
pub fn already_finalized(&self) -> bool
finalization
only.Returns true
if the value in the managed allocation has already been finalized, false
otherwise.
Sourcepub fn mark_alive(&self)
pub fn mark_alive(&self)
Marks the managed allocation as alive.
Every time a Cc
is dropped, the pointed allocation is buffered to be processed in the next collection.
This method simply removes the managed allocation from the buffer, potentially reducing the amount of work
needed to be done by the collector.
This method is a no-op when called on a Cc
pointing to an allocation which is not buffered.
Source§impl<T: Trace> Cc<T>
impl<T: Trace> Cc<T>
Sourcepub fn new_cyclic<F>(f: F) -> Cc<T>
Available on crate feature weak-ptrs
only.
pub fn new_cyclic<F>(f: F) -> Cc<T>
weak-ptrs
only.Creates a new Cc<T>
while providing a Weak<T>
pointer to the allocation,
to allow the creation of a T
which holds a weak pointer to itself.
§Collection
This method may start a collection when the auto-collect
feature is enabled.
See the config
module documentation for more details.
§Panics
Panics if the provided closure or the automatically-stared collection panics.
§Example
#[derive(Trace, Finalize)]
struct Cyclic {
cyclic: Weak<Self>,
}
let cyclic = Cc::new_cyclic(|weak| {
Cyclic {
cyclic: weak.clone(),
}
});
Trait Implementations§
Source§impl<T: ?Sized + Trace> Clone for Cc<T>
impl<T: ?Sized + Trace> Clone for Cc<T>
Source§fn clone(&self) -> Self
fn clone(&self) -> Self
Makes a clone of the Cc
pointer.
This creates another pointer to the same allocation, increasing the strong reference count.
Cloning a Cc
also marks the managed allocation as alive
. See mark_alive
for more details.
§Panics
Panics if the strong reference count exceeds the maximum supported.
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T: ?Sized + Trace + Ord> Ord for Cc<T>
impl<T: ?Sized + Trace + Ord> Ord for Cc<T>
Source§impl<T: ?Sized + Trace + PartialOrd> PartialOrd for Cc<T>
impl<T: ?Sized + Trace + PartialOrd> PartialOrd for Cc<T>
impl<T: ?Sized + Trace + 'static + Unsize<__S>, __S: ?Sized + Trace + 'static> CoerceUnsized<Cc<__S>> for Cc<T>
impl<T: ?Sized + Trace + 'static + Unsize<__S>, __S: ?Sized + Trace + 'static> DispatchFromDyn<Cc<__S>> for Cc<T>
impl<T: ?Sized + Trace + Eq> Eq for Cc<T>
impl<T: ?Sized + Trace + RefUnwindSafe> RefUnwindSafe for Cc<T>
impl<T: ?Sized + Trace + UnwindSafe> UnwindSafe for Cc<T>
Auto Trait Implementations§
impl<T> Freeze for Cc<T>where
T: ?Sized,
impl<T> !Send for Cc<T>
impl<T> !Sync for Cc<T>
impl<T> Unpin for Cc<T>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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)