logos.lang.rc

Module lang · package logos-lang

Types

structRc

struct Rc

Single-threaded reference-counted pointer: shared ownership of a heap-allocated T. Cloning bumps the strong count; the last strong drop runs T’s destructor. NOT Send.

Implements: Drop Clone Deref DerefMut

Fields

inner: *mut RcInner<T>

structRcInner

struct RcInner

Heap control block for Rc/Weak: counters followed by the value, in one allocation. val is dropped when strong reaches 0; the block is freed when weak reaches 0.

Fields

strong: i32

Count of live Rc handles; val is dropped when it reaches 0.

val: T

The stored value.

weak: i32

Count of live Weak handles plus one implicit weak held collectively by strong handles.

structWeak

struct Weak

Non-owning handle to an Rc allocation; does not keep T alive. upgrade() returns Some(Rc) only while a strong reference still exists, else None. Use to break Rc cycles (e.g. a child’s back-pointer to its parent).

Implements: Drop Clone Send Sync Drop Clone

Fields

inner: *mut RcInner<T>

Functions

fnrc_new

fn rc_new(val: T) -> Rc<T>

Creates a new Rc<T> owning val in a fresh single-block heap allocation (strong = 1).