Skip to content

Ptr

Module: std.ptr
Source: std/ptr.zn

Unique[T]

Exclusive owning smart pointer to a heap value


Fields:

ptr: *T,

Constructors:

pub fn new(value: T) Self;

Getters:

pub fn get(*const self) *const T;
pub fn get_mut(*self) *T;

Ownership:

pub fn release(self) *T;
pub fn reset(*self, value: T);

Interfaces:

  • core.ops : Drop, Deref (when T: Copy), DerefPtr
  • core.io : Display (when T: Display), Debug (when T: Debug)

Shared[T]

Shared ownership with a strong count (single threaded). Cloning shares the value and bumps the count. The value is freed once the last owner goes out of scope. The count lives in its own heap cell next to the value


Fields:

ptr: *T,
count: *usize,

Constructors:

pub fn new(value: T) Self;

Getters:

pub fn use_count(*const self) usize;
pub fn is_unique(*const self) bool;
pub fn get(*const self) *const T;
pub fn get_mut(*self) *T;

Interfaces:

  • core.ops : Clone, Drop, Deref (when T: Copy), DerefPtr
  • core.io : Display (when T: Display), Debug (when T: Debug)