mem.buf
A typed allocation with capacity, underneath the array’s live-element count.
All modules · Writing docstrings
Imports and exports
Section titled “Imports and exports”import core.lifecycle.{Drop}import mem.ptr.{Ptr}import mem.allocator.{heap}kind Buf[T]A pointer and capacity. Capacity alone does not mean all slots are initialized.
Buf.ptr
Section titled “Buf.ptr”ptr: Ptr[T]Typed pointer to the allocation.
Buf.cap
Section titled “Buf.cap”cap: IntNumber of allocated slots.
Buf[@T]
Section titled “Buf[@T]”impl Buf[@T]Buf[@T].read
Section titled “Buf[@T].read”func read(self, index: Int): TRead a slot through the typed pointer; callers track which slots are live.
Buf[@T].write
Section titled “Buf[@T].write”func write(self, index: Int, val: T)Write a typed value into the backing allocation.
Buf[@T].grow
Section titled “Buf[@T].grow”func grow(self)Double capacity, or allocate four slots when empty, and move the contents.
Buf[@T] as Drop
Section titled “Buf[@T] as Drop”impl Buf[@T] as DropBuf[@T] as Drop.drop
Section titled “Buf[@T] as Drop.drop”func drop(self)Free the backing allocation. Aliases must not use it afterward.