logos.lang.cell

Module lang · package logos-lang

Types

structBorrowError

struct BorrowError

Returned by RefCell::try_borrow when the value is already mutably borrowed.

structBorrowMutError

struct BorrowMutError

Returned by RefCell::try_borrow_mut when the value is already borrowed.

structCell

struct Cell

Provides safe interior mutability for Copy types via by-value get/set.

Fields

inner: T

structLazyCell

struct LazyCell

Defers initialisation: first force calls the stored fn() -> T and caches the result. Construct with lazy_cell_new.

Fields

cell: OnceCell<T>
init: fn() -> T

structOnceCell

struct OnceCell

Provides write-once interior mutability: set once via &self, then read-only. Construct with once_cell_new (bears the T: Default bound that seeds storage).

Fields

present: bool
storage: T

structRef

struct Ref

Guards a shared borrow of a RefCell value; access via get, released on drop.

Implements: Drop

Fields

state: *mut i32
value: *const T

structRefCell

struct RefCell

Wraps a value with runtime-checked dynamic borrowing via Ref/RefMut guards. Guards hold raw pointers, not lifetimes — a guard must not outlive its cell.

Fields

state: i32
value: T

structRefMut

struct RefMut

Guards an exclusive borrow of a RefCell value; access via get/get_mut, released on drop.

Implements: Drop

Fields

state: *mut i32
value: *mut T

structUnsafeCell

struct UnsafeCell

Wraps a T mutable through &self — the primitive underlying all interior-mutability types. Auto-!Sync and invariant in T; aliasing discipline is the caller’s unsafe obligation.

Fields

value: T

Functions

fncell_take

fn cell_take(c: &Cell<T>) -> T

Takes the cell’s value, leaving T::default() in its place.

fnlazy_cell_new

fn lazy_cell_new(init: fn() -> T) -> LazyCell<T>

Creates a LazyCell that initialises with init on first force.

fnonce_cell_new

fn once_cell_new() -> OnceCell<T>

Creates an empty OnceCell; storage is seeded with T::default() but never observed.

fnref_filter_map

fn ref_filter_map(orig: Ref<T>, f: fn(&T) -> Option) -> Result

Maps a Ref<T> to Ref<U> if f yields Some, else returns the original guard in Err.

fnref_map

fn ref_map(orig: Ref<T>, f: fn(&T) -> &U) -> Ref<U>

Maps a Ref<T> into a Ref<U> for a component of the borrowed data, keeping the borrow.

fnref_mut_map

fn ref_mut_map(orig: RefMut<T>, f: fn(&mut T) -> &mut U) -> RefMut<U>

Maps a RefMut<T> into a RefMut<U> for a component of the borrowed data.

fnrefcell_take

fn refcell_take(c: &RefCell<T>) -> T

Takes the wrapped value, leaving T::default() in its place. Panics if the value is currently borrowed.