Snapshot · Oct 24, 2026 · Frozen documentation
Allocator
Defines the structural raw-storage protocol used by owning containers.
Sn is under heavy development. This reference includes the intended 1.0 design; features may be incomplete in the current compiler. Read the status →
Module std.memory
import std.memory;Public declaration contracts and authored examples. A page can document several related symbols. Implementation bodies are excluded.
Allocator
pub concept Allocator<Self>Defines the structural raw-storage protocol used by owning containers.
An allocator starts and ends allocation storage only; it never begins or ends a T object lifetime. Every operation is unsafe because callers own the exact identity, layout, lifetime, alias, and compatibility proofs.
Example
module example.allocator;
from std.memory import DefaultAllocator, Layout;
fn Main() -> i32 {
var Heap = default(DefaultAllocator);
let StorageLayout = Layout.Of<u64>();
unsafe {
switch Heap.Allocate(StorageLayout) {
case .Ok { Value = Storage } => {
Heap.Free(Storage, StorageLayout);
return 0;
}
case .Err { Error = _ } => return 1;
}
}
}Documentation snapshot: October 24, 2026 About versions ↗