logos.mem.boxed

Module mem · package logos-mem

Types

structBox

struct Box

Owns a heap-allocated T exclusively; move-only, drops the value and frees the block on scope exit (no manual free).

Implements: Send Sync Deref DerefMut Drop

Fields

ptr: *mut T

Functions

fnbox_from_raw

fn box_from_raw(raw: *mut T) -> Box<T>

Reconstitutes a Box from a raw pointer previously produced by box_into_raw (or any pointer to a heap block allocated with the matching layout). The Box re-takes ownership: its Drop will run T’s destructor and free the block. Unsafe — caller guarantees raw is a live, uniquely-owned allocation of T.

fnbox_into_raw

fn box_into_raw(b: Box<T>) -> *mut T

Consumes the Box and returns its raw heap pointer without running Box’s Drop. The heap block is NOT freed — ownership of the allocation transfers to the caller, who must reconstitute a Box via box_from_raw or free it manually.

fnbox_leak

fn box_leak(b: Box<T>) -> &mut T

Consumes the Box and leaks its contents, returning a &mut T that lives for the rest of the program. The allocation is never freed.

fnbox_new

fn box_new(val: T) -> Box<T>

Allocates a heap block sized for T, moves val into it, and returns the Box.

fnbox_pin

fn box_pin(val: T) -> Pin<Box<T>>

Heap-pins val, moving it into a new Box first. Sound for any T: the value’s unpinned phase ends at this call, before pinning.

fnbox_take

fn box_take(b: Box<T>) -> T

Consumes the Box, moves its contents out (no drop of the contents — ownership transfers to the caller), and frees the heap block. The compiler desugars let x = *b over a move-typed Box to this call.