velt/mem
API referenceFacts about how values are stored, for code that manages its own memory layout, such as a container with slots for many values (Rust's std::mem), and Arena, a typed memory pool. Most programs never need this module; the collections are built on it. For a walkthrough, read the guide.
Exports
value's type own memory that dropping one releases: strings, arrays, objects and class instances (and structs or unions holding any) do; numbers, bool and SIMD vectors do not.ArenaA typed memory pool: values named by u32 index, released together by reset().BlankA value that owns no memory, for a container to keep in the slots it does not use (an array of plain T has no holes), so that a value it removes is released at once: "" for a string.Re-exported from velt/mem/needs_drop
function needsDrop<T>(value: T): boolWhether values of value's type own memory that dropping one releases: strings, arrays,
objects and class instances (and structs or unions holding any) do; numbers, bool and
SIMD vectors do not. The same for every value of a type, and a constant where the type is
known, so if (needsDrop(x)) costs nothing: a generic container can skip bookkeeping that
only matters for values that hold memory (Rust's std::mem::needs_drop).
Re-exported from velt/mem/arena
class Arena<T>A typed memory pool: values named by u32 index, released together by reset().
constructor(capacity: usize = 0)capacity values fit before the pool first grows.
get length(): usizeNumber of values allocated since the last reset().
alloc(value: T): u32Stores value; returns its index.
get(index: u32): TThe value at index (a copy for Copy types, else a clone).
set(index: u32, value: T)Replaces the value at index.
reset()Drops every value but keeps the memory: the next allocations reuse it.
Re-exported from velt/mem/blank
interface Blank<T>A value that owns no memory, for a container to keep in the slots it does not use (an array
of plain T has no holes), so that a value it removes is released at once: "" for a
string. Every type has it: one whose values own no memory (needsDrop is false) is its own
blank, and one without a blank value gives the value itself (hasBlank() is false), which a
container then replaces when that value goes. A type implements Blank to give one.
hasBlank(): boolWhether blank() owns no memory (the same for every value of the type).
blank(): TA value that owns no memory when hasBlank(); else this value.