Struct GCArc
pub struct GCArc<T> {
ptr: NonNull<Container<T>>,
}Expand description
A reference counted smart pointer that allows shared ownership of a value of type T, allocated with a crate::GCAllocator.
Fields§
§ptr: NonNull<Container<T>>Implementations§
§impl<T> GCArc<T>
impl<T> GCArc<T>
fn new(el: Box<Container<T>>) -> GCArc<T>
unsafe fn set(&mut self, val: T)
unsafe fn set(&mut self, val: T)
Function should only be used by the allocator to be able to rewrite to the memory without a new allocation while maintaining a reference in the allocator.
pub fn into_raw(self) -> *const T
pub fn into_raw(self) -> *const T
Consumes the reference container and returns the raw pointer to the memory element Without decrementing the reference count To avoid a memory leak, the pointer must be converted back to GCContainerRef using GCContainerRef::from_raw
pub unsafe fn from_raw(ptr: *const T) -> GCArc<T>
pub unsafe fn from_raw(ptr: *const T) -> GCArc<T>
Constructs a GCContainerRef from a raw pointer
§Safety
The raw pointer must have been previously obtained by calling GCContainerRef::into_raw. The user must also ensure that T used in GCContainerRef::into_raw is the same as the one used in this function