Development · Evolving reference
AllocationError
Classifies recoverable raw-storage and layout failures.
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.
AllocationError
pub enum AllocationErrorClassifies recoverable raw-storage and layout failures.
The cases are portable and allocation-free. They intentionally preserve no target allocator status code; target-private adapters translate at their boundary.
Example
module example.allocation_error;
from std.memory import AllocationError, Layout;
fn Main() -> i32 {
switch Layout.ArrayOf<u64>(4) {
case .Ok { Value = _ } => return 0;
case .Err { Error = Error } => {
if Error == .SizeOverflow { return 2; }
return 1;
}
}
}AllocationError.OutOfMemory
OutOfMemory;Reports that the allocator could not acquire storage.
AllocationError.UnsupportedAlignment
UnsupportedAlignment;Reports that the allocator cannot honor a valid requested alignment.
AllocationError.InvalidLayout
InvalidLayout;Reports a zero, non-power-of-two, or otherwise invalid layout.
AllocationError.SizeOverflow
SizeOverflow;Reports that a requested byte-count computation is not representable.
Documentation snapshot: October 24, 2026 About versions ↗