[−][src]Function auto_cc::cc
pub fn cc<T: Trace>(value: T) -> Cc<T>
Wraps Cc::new
with some logic to automatically track the number of root objects in a garbage cycle
and automatically collecting them when needed.
This function allows a maximum of 128
buffered roots before triggering a collection.
This function will perform a collection before allocating a new Cc::new
,
so it is recommended to manually call collect_cycles
after any code
where cycles are likely to be created has finished to perform final cleanup.
This function is meant to be a drop-in replacement for Cc::new
where needed,
but does not modify or otherwise touch Cc<T>
.
Cc::new
should be preferred unless it is known that an arbitrary number of cycles
are likely to be created outside of the programmer's control and cleaning them up during normal
execution is desirable.
Example
use auto_cc::cc; let x = cc( 42u8 );