Module prelude

prelude

Prelude — automatically imported into every Yo source file.

Provides core language primitives: traits (Comptime, Runtime, Clone, Eq, Ord, Hash, …), fundamental types (Option, Result, Rc, Slice, Range, String, …), operator traits (Add, Sub, …), type reflection (TypeInfo), conversion (Into, From), the async runtime (Io, Future, JoinHandle), and derive rules.

Do NOT import std/prelude — it is loaded automatically and an explicit import will produce a compile error.

Stability

The prelude is the one module whose surface is a language decision, not a library one: every name here is in scope in every Yo file, so adding one can shadow a user's binding and removing one breaks every program. Treat additions as breaking changes in review even though the compiler will not call them that.

Broadly stable: the core traits (Clone, Eq, Ord, Hash, Dispose, Send, the operator traits), Option, Result, Rc, Range, the numeric types and their inherent methods, and the async vocabulary (Io, Future, JoinHandle). These have Rust's names and meanings and are not expected to move.

The byte-conversion battery is now ONE blanket impl, not ten copies. to_be_bytes, to_le_bytes, from_be_bytes and from_le_bytes return Array(u8, T.BYTES), taking the length from the receiver's own associated constant, which value substitution in a type position made expressible (plans/backlog/VALUE_SUBSTITUTION_IN_TYPE_POSITIONS.md). usize and isize therefore HAVE them now, which they could not before: their width is the target's, and _USIZE_BYTES derives it the same way _USIZE_BITS derives the bit width. BYTES is declared through the ByteWidth trait rather than inherently beside BITS, because an inherent associated constant does not resolve in a length position (issues/an-inherent-associated-constant-does-not-resolve-as-an-array-length.md). This is additive for callers — same names, same meanings — but the methods are defined in a different place, so a doc link may move.

Types

Pragma enum
Pragma

File-level privilege flag for the pragma(...) builtin. Declared at the top of a Yo file (e.g. pragma(Pragma.AllowUnsafe);) to opt the file into compiler-recognized behaviors. See plans/reference/MEMORY_SAFETY.md.

Variants

VariantFieldsDescription
AllowUnsafe

File is permitted to use raw pointer ops, unsafe(...), asm(...), and extern(...). Without this, those constructs produce compile errors.

AllowMacroDef

File is permitted to DEFINE macro functions — quote(...) parameters and unquote(...) return types. CALLING macros (if, for, collection literals, …) needs no pragma. Recognized at the AST level so it also works in SkipPrelude files. See plans/reference/MACRO_POLICY.md.

SkipPrelude

Disable the auto-import of std/prelude. Used by the prelude itself, and by any tool/test that wants to bootstrap manually. Recognized at the AST level before the prelude loads.

SkipWasm

Test-runner directive: skip this test file on ALL WASM targets.

SkipWasm32Emscripten

Test-runner directive: skip when target is wasm32-unknown-emscripten.

SkipWasm32Wasi

Test-runner directive: skip when target is wasm32-wasip1.

SkipWindows

File is skipped by the test runner when the target OS is Windows. For tests that depend on a POSIX-only or not-yet-ported platform facility (e.g. std/crypto/tls needs OpenSSL, absent on the Windows runners — Schannel is the deferred Windows path). Mirrors the SkipWasm32* variants.

NeedsLeakVerdict

Test-runner directive: this file's tests only have a failure mode when the LeakSanitizer verdict is applied — they exercise a construct and assert values that were never wrong, so a leak is the one defect they can catch. When the run stages the verdict off (YO_TEST_LEAK_VERDICT=0) or builds no ASan test binary (a wasm target, --disable-sanitize, a non-address YO_TEST_SANITIZE), the runner SKIPS the file with a line that says so instead of reporting a vacuous pass. issues/fixed/leak-regression-tests-cannot-fail-in-ci-leak-verdicts-are-off-everywhere.md

Verify

Formal verification: contracts in this file are proof obligations. Phase 0 only registers the pragma; later phases will hook in verification. See plans/backlog/FORMAL_VERIFICATION.md.

VerifyOrAssert

Formal verification: try to prove, fall back to runtime assert when proof times out. The production mode for verified code.

NoContracts

Formal verification: erase contract clauses entirely (no proof, no runtime assert). For release/benchmark builds.

StrictBorrow

Strict borrowed loops: inside for(coll, inout(x) => …) bodies of this file, a call the compiler cannot prove harmless to the borrowed element — a mutating method on the borrowed collection or an alias of it, or a callee whose effects are unknown (a closure, a dynamic dispatch, a function pointer) — is a compile error instead of a runtime borrow panic. See docs/FLOWABILITY.md.

Trait Implementations

Eq
Methods
== : (Pragma) fn(lhs : Pragma, rhs : Pragma) -> bool

Parameters

NameTypeNotes
lhsPragma
rhsPragma

Returns: bool

!= : (Pragma) fn(lhs : Pragma, rhs : Pragma) -> bool

Parameters

NameTypeNotes
lhsPragma
rhsPragma

Returns: bool

clone : (Pragma) fn(inout(self) : Pragma) -> Pragma

Create an independent clone of self.

Parameters

NameTypeNotes
selfPragma

Returns: Pragma

GcTracer newtype
GcTracer

=== Cycle-GC tracing === GcTracer carries the cycle collector's edge-registration callback (an opaque raw pointer). A Trace impl calls tracer.visit(slot) once per outgoing edge, passing a POINTER to where the child lives (a struct field or a container buffer element). The raw callback is never touched directly.

Fields

NameTypeDescription
_callback*(u8)
impl(GcTracer, ...)
visit : (GcTracer) fn(generic(T) self : GcTracer, slot : *(T)) -> unit

Trace one outgoing edge. slot points at where the child lives; the collector reads *slot WITHOUT touching its reference count — registering the edge if it is a managed handle and recursing inline through value structure otherwise. Passing the slot pointer (not the element by value) keeps tracing RC-neutral: a by-value managed handle would be dup'd then dropped, freeing a live element mid-collection.

Parameters

NameTypeNotes
selfGcTracer
slot*(T)

Returns: unit

AllocatorVTable

The functions behind an Allocator. Implementing one needs pragma(Pragma.AllowUnsafe).

  • alloc(ctx, size) returns a block of at least size bytes aligned to 16, or .None.
  • realloc(ctx, ptr, new_size) resizes a block this vtable's alloc returned, keeping its first min(old, new_size) bytes. .None leaves the original block untouched and still owned by the caller.
  • free(ctx, ptr) releases such a block.

There is no size at free and no aligned family: every container buffer and every RC block uses the plain family (see std/allocator.yo's module notes).

Fields

NameTypeDescription
allocfn(ctx : ?(*(void)), size : usize) -> ?(*(void))
reallocfn(ctx : ?(*(void)), ptr : ?(*(void)), new_size : usize) -> ?(*(void))
freefn(ctx : ?(*(void)), ptr : ?(*(void))) -> unit
Allocator struct
Allocator

An allocator value: an opaque context plus an immortal vtable. Two words, copied freely; it is not reference counted, because an allocator must not itself need an allocator.

Fields

NameTypeDescription
ctx?(*(void))
vtable*(AllocatorVTable)

Trait Implementations

impl(Allocator, Send())
impl(Allocator, Sync())
Methods
clone : (Allocator) fn(inout(self) : Allocator) -> Allocator

Create an independent clone of self.

Parameters

NameTypeNotes
selfAllocator

Returns: Allocator

global : (Allocator) fn() -> Allocator

Returns: Allocator

alloc : (Allocator) fn(self : Allocator, size : usize) -> ?(*(void))

Parameters

NameTypeNotes
selfAllocator
sizeusize

Returns: ?(*(void))

realloc : (Allocator) fn(ptr : *(void), new_size : usize) -> ?(*(void))

Parameters

NameTypeNotes
ptr*(void)
new_sizeusize

Returns: ?(*(void))

free : (Allocator) fn(ptr : ?(*(void))) -> unit

Parameters

NameTypeNotes
ptr?(*(void))

Returns: unit

owner_of : (Allocator) fn(ptr : *(void)) -> Allocator

Parameters

NameTypeNotes
ptr*(void)

Returns: Allocator

same : (Allocator) fn(self : Allocator, other : Allocator) -> bool

Parameters

NameTypeNotes
selfAllocator
otherAllocator

Returns: bool

global : (Allocator) fn() -> Allocator

Returns: Allocator

alloc : (Allocator) fn(self : Allocator, size : usize) -> ?(*(void))

Parameters

NameTypeNotes
selfAllocator
sizeusize

Returns: ?(*(void))

realloc : (Allocator) fn(ptr : *(void), new_size : usize) -> ?(*(void))

Parameters

NameTypeNotes
ptr*(void)
new_sizeusize

Returns: ?(*(void))

free : (Allocator) fn(ptr : ?(*(void))) -> unit

Parameters

NameTypeNotes
ptr?(*(void))

Returns: unit

owner_of : (Allocator) fn(ptr : *(void)) -> Allocator

Parameters

NameTypeNotes
ptr*(void)

Returns: Allocator

same : (Allocator) fn(self : Allocator, other : Allocator) -> bool

Parameters

NameTypeNotes
selfAllocator
otherAllocator

Returns: bool

Range type-function
fn(T : Type) -> Type

Half-open range start..end (excludes end).

Type Parameters

NameTypeNotes
TTypecomptime

Trait Implementations

impl(Range(i8), Iterator(...))
Item : i8
next : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(i8)

impl(Range(i16), Iterator(...))
Item : i16
next : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(i8)

impl(Range(i32), Iterator(...))
Item : i32
next : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(i8)

impl(Range(i64), Iterator(...))
Item : i64
next : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(i8)

impl(Range(isize), Iterator(...))
Item : isize
next : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(i8)

impl(Range(u8), Iterator(...))
Item : u8
next : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(i8)

impl(Range(u16), Iterator(...))
Item : u16
next : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(i8)

impl(Range(u32), Iterator(...))
Item : u32
next : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(i8)

impl(Range(u64), Iterator(...))
Item : u64
next : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(i8)

impl(Range(usize), Iterator(...))
Item : usize
next : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(i8)

impl(Range(i8), DoubleEndedIterator(...))
Item : i8
next_back : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Returns: Option(i8)

impl(Range(i16), DoubleEndedIterator(...))
Item : i16
next_back : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Returns: Option(i8)

impl(Range(i32), DoubleEndedIterator(...))
Item : i32
next_back : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Returns: Option(i8)

impl(Range(i64), DoubleEndedIterator(...))
Item : i64
next_back : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Returns: Option(i8)

impl(Range(isize), DoubleEndedIterator(...))
Item : isize
next_back : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Returns: Option(i8)

impl(Range(u8), DoubleEndedIterator(...))
Item : u8
next_back : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Returns: Option(i8)

impl(Range(u16), DoubleEndedIterator(...))
Item : u16
next_back : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Returns: Option(i8)

impl(Range(u32), DoubleEndedIterator(...))
Item : u32
next_back : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Returns: Option(i8)

impl(Range(u64), DoubleEndedIterator(...))
Item : u64
next_back : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Returns: Option(i8)

impl(Range(usize), DoubleEndedIterator(...))
Item : usize
next_back : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Returns: Option(i8)

RangeInclusive type-function
fn(T : Type) -> Type

Inclusive range start..=end (includes end).

Type Parameters

NameTypeNotes
TTypecomptime

Trait Implementations

impl(RangeInclusive(i8), Iterator(...))
Item : i8
next : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(i8)

impl(RangeInclusive(i16), Iterator(...))
Item : i16
next : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(i8)

impl(RangeInclusive(i32), Iterator(...))
Item : i32
next : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(i8)

impl(RangeInclusive(i64), Iterator(...))
Item : i64
next : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(i8)

impl(RangeInclusive(isize), Iterator(...))
Item : isize
next : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(i8)

impl(RangeInclusive(u8), Iterator(...))
Item : u8
next : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(i8)

impl(RangeInclusive(u16), Iterator(...))
Item : u16
next : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(i8)

impl(RangeInclusive(u32), Iterator(...))
Item : u32
next : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(i8)

impl(RangeInclusive(u64), Iterator(...))
Item : u64
next : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(i8)

impl(RangeInclusive(usize), Iterator(...))
Item : usize
next : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(i8)

impl(RangeInclusive(i8), DoubleEndedIterator(...))
Item : i8
next_back : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Returns: Option(i8)

impl(RangeInclusive(i16), DoubleEndedIterator(...))
Item : i16
next_back : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Returns: Option(i8)

impl(RangeInclusive(i32), DoubleEndedIterator(...))
Item : i32
next_back : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Returns: Option(i8)

impl(RangeInclusive(i64), DoubleEndedIterator(...))
Item : i64
next_back : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Returns: Option(i8)

impl(RangeInclusive(isize), DoubleEndedIterator(...))
Item : isize
next_back : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Returns: Option(i8)

impl(RangeInclusive(u8), DoubleEndedIterator(...))
Item : u8
next_back : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Returns: Option(i8)

impl(RangeInclusive(u16), DoubleEndedIterator(...))
Item : u16
next_back : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Returns: Option(i8)

impl(RangeInclusive(u32), DoubleEndedIterator(...))
Item : u32
next_back : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Returns: Option(i8)

impl(RangeInclusive(u64), DoubleEndedIterator(...))
Item : u64
next_back : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Returns: Option(i8)

impl(RangeInclusive(usize), DoubleEndedIterator(...))
Item : usize
next_back : (fn(inout(self) : Self) -> Option(i8))

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Returns: Option(i8)

Ordering enum
Ordering

Ordering — result of a comparison.

Variants

VariantFieldsDescription
Less

Left-hand side is less than right-hand side.

Equal

Both sides are equal.

Greater

Left-hand side is greater than right-hand side.

Methods
clone : (Ordering) fn(inout(self) : Ordering) -> Ordering

Create an independent clone of self.

Parameters

NameTypeNotes
selfOrdering

Returns: Ordering

Reverse type-function
fn(T : Type) -> Type

Reverse(T) — a wrapper whose Ord is T's, inverted (Rust's core::cmp::Reverse).

It turns any max-ordered structure into a min-ordered one without a second implementation. PriorityQueue is a MAX-heap (D11), so a min-heap is:

pq := PriorityQueue(Reverse(i32)).new();
pq.push(Reverse(i32)(i32(5)));
pq.push(Reverse(i32)(i32(1)));
pq.pop().unwrap().value;  // 1 — the SMALLEST

It is equally the way to sort descending: list.sort_by((a, b) -> (Reverse(i32)(a) < Reverse(i32)(b))).

Type Parameters

NameTypeNotes
TTypecomptime

Trait Implementations

impl(generic(T : Type), where(T <: Eq(T)), Reverse(T), Eq(Reverse(T))(...))
impl(generic(T : Type), where(T <: Ord(T)), Reverse(T), Ord(Reverse(T))(...))
comptime_str type-alias
comptime_str

Trait Implementations

RawSlice type-function
fn(T : Type) -> Type

RawSlice — a plain ptr+len pair for PRIVILEGED (pragma'd) code: C interop and std internals. Carries a raw pointer, so the existing raw-pointer gates apply: safe code cannot name or construct it. Replaces the builtin Slice(T) for internal plumbing (plans/archive/SLICE_REWORK.md step 4).

Type Parameters

NameTypeNotes
TTypecomptime
ComptimeValue

ComptimeValue — a data document read at COMPILE time (plans/archive/BUILD_AND_DEPENDENCY_SYSTEM_REDESIGN.md §5.2).

comptime_json_parse and comptime_toml_parse return one of these. No runtime container can exist at compile time, so the tree is built from ComptimeList and comptime scalars only.

A table keeps PARALLEL key and value lists, the shape std/encoding/json's JsonValue.Object and std/encoding/toml's TomlValue.Table already use. The plan sketched a separate ComptimeEntry struct instead; that shape is not expressible, because ComptimeEntry.value : ComptimeValue and ComptimeValue.Table(… ComptimeEntry) are mutually recursive TYPE definitions and the evaluator rejects those ("cyclic definition"). Parallel lists need only Self, which is fine. Keys are in document order.

Variants

VariantFieldsDescription
Null

JSON null. TOML has no null, so a TOML document never yields it.

Boolv: bool

true / false.

Intv: comptime_int

An integer. JSON numbers that are whole become Int.

Floatv: comptime_float

A non-integral number.

Strv: comptime_str

str — static string view (fieldless)

Listitems: ComptimeList(ComptimeValue)

An array, in document order.

Tablekeys: ComptimeList(comptime_str), values: ComptimeList(ComptimeValue)

A table/object: keys(i) names values(i), in document order.

Trait Implementations

impl(ComptimeValue, Comptime())
impl(ComptimeValue, Acyclic())
impl(ComptimeValue, ...)
get : (ComptimeValue) fn(self : ComptimeValue, key : comptime_str) -> ComptimeValue

The value under key, or .Null when this is not a table or has no such key. .Null rather than an Option because an Option of a comptime value is itself awkward to match at compile time, and a missing key and a JSON null behave the same way for every use this exists for.

Parameters

NameTypeNotes
selfComptimeValuecomptime
keycomptime_strcomptime

Returns: ComptimeValue

at : (ComptimeValue) fn(self : ComptimeValue, i : usize) -> ComptimeValue

The element at i, or .Null when this is not a list or i is past its end.

Parameters

NameTypeNotes
selfComptimeValuecomptime
iusizecomptime

Returns: ComptimeValue

len : (ComptimeValue) fn(self : ComptimeValue) -> usize

The number of elements of a list, or entries of a table; 0 otherwise.

Parameters

NameTypeNotes
selfComptimeValuecomptime

Returns: usize

as_str : (ComptimeValue) fn(self : ComptimeValue, fallback : comptime_str) -> comptime_str

The string this holds, or fallback when it holds anything else.

Parameters

NameTypeNotes
selfComptimeValuecomptime
fallbackcomptime_strcomptime

Returns: comptime_str

as_int : (ComptimeValue) fn(self : ComptimeValue, fallback : comptime_int) -> comptime_int

The integer this holds, or fallback when it holds anything else.

Parameters

NameTypeNotes
selfComptimeValuecomptime
fallbackcomptime_intcomptime

Returns: comptime_int

as_bool : (ComptimeValue) fn(self : ComptimeValue, fallback : bool) -> bool

The boolean this holds, or fallback when it holds anything else.

Parameters

NameTypeNotes
selfComptimeValuecomptime
fallbackboolcomptime

Returns: bool

is_null : (ComptimeValue) fn(self : ComptimeValue) -> bool

True when this is .Null — a missing key or an explicit JSON null.

Parameters

NameTypeNotes
selfComptimeValuecomptime

Returns: bool

ExprList type-alias
ComptimeList(Expr)

ExprList

Expr type-alias
Expr

Trait Implementations

Type type-alias
Type

Trait Implementations

StructKind enum
StructKind

Type reflection metadata structs — used by Type.get_info(). StructKind — discriminant for struct flavors.

Variants

VariantFieldsDescription
Struct

Regular value struct.

Object

Reference-counted object.

AtomicObject

Atomic reference-counted object.

NewType

Single-field newtype wrapper.

Trait Implementations

impl(StructKind, Comptime())
TypeFieldInfo struct
TypeFieldInfo

TypeFieldInfo — metadata for a single struct/object field.

Fields

NameTypeDescription
namecomptime_str

Variant name.

field_typeType

Field type.

Trait Implementations

impl(TypeFieldInfo, Comptime())
impl(TypeFieldInfo, ...)
to_expr : (TypeFieldInfo) fn(self : TypeFieldInfo) -> Expr

Convert the field name to an AST expression (for metaprogramming).

Parameters

NameTypeNotes
selfTypeFieldInfocomptime

Returns: Expr

TraitInfo struct
TraitInfo

TraitInfo — lightweight reference to a trait type.

Fields

NameTypeDescription
trait_typeType

The trait's Type value.

Trait Implementations

impl(TraitInfo, Comptime())
TraitFieldInfo

TraitFieldInfo — metadata for a single trait field.

Fields

NameTypeDescription
namecomptime_str

Variant name.

field_typeType

Field type.

is_associated_typebool

true if this field is an associated type (not a method).

Trait Implementations

impl(TraitFieldInfo, Comptime())
ParamInfo struct
ParamInfo

ParamInfo — metadata for a function parameter.

Fields

NameTypeDescription
namecomptime_str

Variant name.

param_typeType

Parameter type.

is_comptimebool

true if the parameter is compile-time (comptime).

is_quotebool

true if the parameter uses quote.

is_variadicbool

true if the parameter is variadic.

Trait Implementations

impl(ParamInfo, Comptime())
ForallParamInfo

ForallParamInfo — metadata for a generic type parameter.

Fields

NameTypeDescription
namecomptime_str

Variant name.

param_typeType

Parameter type.

Trait Implementations

impl(ForallParamInfo, Comptime())
ImplicitParamInfo

ImplicitParamInfo — metadata for a using/effect parameter.

Fields

NameTypeDescription
namecomptime_str

Variant name.

param_typeType

Parameter type.

Trait Implementations

impl(ImplicitParamInfo, Comptime())
FunctionInfo struct
FunctionInfo

FunctionInfo — metadata for a function type.

Fields

NameTypeDescription
paramsComptimeList(ParamInfo)

Regular parameters.

return_typeType

Return type.

forall_paramsComptimeList(ForallParamInfo)

Optional generic parameters for generic types.

implicit_paramsComptimeList(ImplicitParamInfo)

Implicit using parameters.

is_closurebool

true if this is a closure type.

Trait Implementations

impl(FunctionInfo, Comptime())
TraitKind enum
TraitKind

TraitKind — discriminant for different trait flavors.

Variants

VariantFieldsDescription
Futurechild: Type, effects: ComptimeList(TraitInfo)

A Future trait with child type and effects.

Fncall: FunctionInfo

A callable Fn trait with function info.

Normal

A normal user-defined trait.

Trait Implementations

impl(TraitKind, Comptime())
VariantInfo struct
VariantInfo

VariantInfo — metadata for an enum variant.

Fields

NameTypeDescription
namecomptime_str

Variant name.

fieldsComptimeList(TypeFieldInfo)

Variant fields (may be empty for unit variants).

_enum_typeType
_variant_indexusize

Trait Implementations

impl(VariantInfo, Comptime())
TypeInfo enum
TypeInfo

TypeInfo — compile-time enum representing rich type metadata. Returned by Type.get_info() for compile-time type reflection.

Variants

VariantFieldsDescription
Unit
Bool

true / false.

Usize
Isize
U8
I8
U16
I16
U32
I32
U64
I64
F32
F64
Char
Short
UShort
Int

An integer. JSON numbers that are whole become Int.

UInt
Long
ULong
LongLong
ULongLong
LongDouble
Void
Str

str — static string view (fieldless)

Arrayelement: Type, length: comptime_int
Tuplefields: ComptimeList(TypeFieldInfo)
Structfields: ComptimeList(TypeFieldInfo), kind: StructKind

Regular value struct.

Enumvariants: ComptimeList(VariantInfo)
Unionfields: ComptimeList(TypeFieldInfo)
Functioninfo: FunctionInfo
Ptrpointee: Type
Isochild: Type
Dynrequired_traits: ComptimeList(TraitInfo), negative_traits: ComptimeList(TraitInfo)
Traitfields: ComptimeList(TraitFieldInfo), kind: TraitKind
Typelevel: comptime_int
Somename: comptime_str, required_traits: ComptimeList(TraitInfo), negative_traits: ComptimeList(TraitInfo), resolved_type: Type
ComptimeInt
ComptimeFloat
ComptimeStr
ComptimeListelement: Type
Expr
TypeApplication

Trait Implementations

impl(TypeInfo, Comptime())
impl(TypeInfo, ...)
is_struct : (TypeInfo) fn(self : TypeInfo) -> bool

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_enum : (TypeInfo) fn(self : TypeInfo) -> bool

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_union : (TypeInfo) fn(self : TypeInfo) -> bool

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_tuple : (TypeInfo) fn(self : TypeInfo) -> bool

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_array : (TypeInfo) fn(self : TypeInfo) -> bool

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_str : (TypeInfo) fn(self : TypeInfo) -> bool

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_function : (TypeInfo) fn(self : TypeInfo) -> bool

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_pointer : (TypeInfo) fn(self : TypeInfo) -> bool

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_trait : (TypeInfo) fn(self : TypeInfo) -> bool

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_void : (TypeInfo) fn(self : TypeInfo) -> bool

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_primitive : (TypeInfo) fn(self : TypeInfo) -> bool

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_integer : (TypeInfo) fn(self : TypeInfo) -> bool

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_float : (TypeInfo) fn(self : TypeInfo) -> bool

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_comptime : (TypeInfo) fn(self : TypeInfo) -> bool

true if the parameter is compile-time (comptime).

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_numeric : (TypeInfo) fn(self : TypeInfo) -> bool

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

FieldInfo struct
FieldInfo

FieldInfo — compile-time struct field metadata for derive rules (legacy alias).

Fields

NameTypeDescription
namecomptime_str

Variant name.

field_typeType

Field type.

Trait Implementations

impl(FieldInfo, Comptime())
impl(FieldInfo, ...)
to_expr : (FieldInfo) fn(self : FieldInfo) -> Expr

Convert the field name to a quoted expression.

Parameters

NameTypeNotes
selfFieldInfocomptime

Returns: Expr

Option type-function
fn(T : Type) -> Type

Option — a value that may or may not be present.

Option(T) has two variants:

  • .Some(value) — contains a value of type T
  • .None — contains no value

Example

(x : Option(i32)) = .Some(i32(42));
assert(x.is_some(), "expected Some");
assert(x.unwrap() == i32(42), "expected 42");

Type Parameters

NameTypeNotes
TTypecomptime

Trait Implementations

impl(generic(T : Type), Option(T), ...)
unwrap : (fn(self : Self) -> T)

Extract the contained value, panicking with a message if None.

Returns: T

unwrap_or : (fn(self : Self, or_value : T) -> T)

Extract the contained value, or return or_value if None.

Returns: T

is_some : (fn(self : Self) -> bool)

Return true if the option contains a value.

Returns: bool

is_none : (fn(self : Self) -> bool)

Return true if the option is None.

Returns: bool

impl(generic(T : Type), Option(T), ...)
map : (fn(generic(B : Type), self : Self, f : Impl(Fn(a : T) -> B)) -> Option(B))

Apply f to the contained value (if Some), or return None.

Returns: Option(B)

and_then : (fn(generic(B : Type), self : Self, f : Impl(Fn(a : T) -> Option(B))) -> Option(B))

Apply f to the contained value (if Some) and flatten the result.

Returns: Option(B)

filter : (fn(self : Self, predicate : Impl(Fn(a : T) -> bool)) -> Option(T))

Return Some(value) if the predicate returns true, otherwise None.

Returns: Option(T)

or_else : (fn(self : Self, f : Impl(Fn() -> Option(T))) -> Option(T))

Return this option if Some, otherwise call f and return its result.

Returns: Option(T)

map_or : (fn(generic(B : Type), self : Self, default_val : B, f : Impl(Fn(a : T) -> B)) -> B)

Apply f if Some, otherwise return default_val.

Returns: B

map_or_else : (fn(generic(B : Type), self : Self, default_fn : Impl(Fn() -> B), f : Impl(Fn(a : T) -> B)) -> B)

Apply f if Some, otherwise call default_fn.

Returns: B

and : (fn(generic(B : Type), self : Self, optb : Option(B)) -> Option(B))

Return optb if self is Some, otherwise None.

Returns: Option(B)

or : (fn(self : Self, optb : Option(T)) -> Option(T))

Return self if Some, otherwise return optb.

Returns: Option(T)

unwrap_or_else : (fn(self : Self, f : Impl(Fn() -> T)) -> T)

Extract the contained value, or call f to produce a default.

Returns: T

expect : (fn(self : Self, msg : str) -> T)

Extract the contained value, panicking with msg if None.

Returns: T

is_some_and : (fn(self : Self, f : Impl(Fn(a : T) -> bool)) -> bool)

Return true if Some and the predicate holds for the value.

Returns: bool

inspect : (fn(self : Self, f : Impl(Fn(a : T) -> unit)) -> Option(T))

Call f with the contained value (if Some), then return the option.

Returns: Option(T)

impl(generic(T : Type), Option(T), ...)
take : (fn(inout(self) : Self) -> Option(T))

Take the value out of the option, leaving None in its place.

Returns: Option(T)

replace : (fn(inout(self) : Self, value : T) -> Option(T))

Replace the contained value with Some(value), returning the old option.

Returns: Option(T)

impl(generic(T : Type), Option(Option(T)), ...)
flatten : (fn(self : Self) -> Option(T))

Collapse one level of nesting.

Returns: Option(T)

impl(generic(T : Type), Option(T), Default(...))
default : (fn() -> Self)

The default value of the type.

Returns: Self

impl(generic(T : Type), where(T <: Default), Option(T), ...)
unwrap_or_default : (fn(self : Self) -> T)

Extract the contained value, or T's default when None.

Returns: T

impl(generic(T : Type), where(T <: Comptime), Option(T), Comptime())
impl(generic(T : Type), where(T <: Comptime), Option(T), ...)
comptime_unwrap : (fn(comptime(self) : Self) -> comptime(T))

Compile-time unwrap — panics at compile-time if None.

Returns: comptime(T)

comptime_unwrap_or : (fn(comptime(self) : Self, comptime(or_value) : T) -> comptime(T))

Returns: comptime(T)

comptime_is_some : (fn(comptime(self) : Self) -> comptime(bool))

Returns: comptime(bool)

comptime_is_none : (fn(comptime(self) : Self) -> comptime(bool))

Returns: comptime(bool)

impl(generic(T : Type, E : Type), Option(Result(T, E)), ...)
transpose : (fn(self : Self) -> Result(Option(T), E))

Some(Ok(v)) becomes Ok(Some(v)), None becomes Ok(None), Some(Err(e)) becomes Err(e).

Returns: Result(Option(T), E)

impl(generic(T : Type), Option(T), ...)
ok_or : (fn(generic(E : Type), self : Self, err : E) -> Result(T, E))

Convert Some(value) to Ok(value), or return Err(err) if None.

Returns: Result(T, E)

ok_or_else : (fn(generic(E : Type), self : Self, err_fn : Impl(Fn() -> E)) -> Result(T, E))

Convert Some(value) to Ok(value), or call err_fn to produce Err if None.

Returns: Result(T, E)

impl(generic(T : Type), where(T <: Clone), Option(T), Clone(...))
clone : ( self -> match( self, .None => Option(T).None, .Some(v) => Option(T).Some(v.clone()) ) )
impl(generic(T : Type), where(T <: Copy), Option(T), Copy())
impl(generic(T : Type), where(T <: Eq(T)), Option(T), Eq(Option(T)))
impl(generic(T : Type), where(T <: Ord(T)), Option(T), Ord(Option(T)))
impl(generic(T : Type), where(T <: Hash), Option(T), Hash(...))
hash : (fn(generic(H : Type), inout(self) : Self, inout(hasher) : H, where(H <: Hasher)) -> unit)

Feed this value's identity into hasher.

Parameters

NameTypeNotes
HType

Returns: unit

impl(generic(T : Type), Option(T), ...)
zip : (fn(generic(B : Type), self : Self, other : Option(B)) -> Option(IterPair(T, B)))

Some(a).zip(Some(b)) is Some(IterPair(a, b)); anything else is None.

Returns: Option(IterPair(T, B))

? type-function
fn(T : Type) -> Type

Type Parameters

NameTypeNotes
TTypecomptime
DeriveContext struct
DeriveContext

DeriveContext — context passed to derive rule functions (needs Option). Used by the derive macro to generate trait implementations.

Fields

NameTypeDescription
targetExpr

The AST expression for the target type.

forall_paramsOption(Expr)

Optional generic parameters for generic types.

where_clauseOption(Expr)

Optional where clause for constrained generics.

Trait Implementations

impl(DeriveContext, Comptime())
impl(DeriveContext, ...)
make_impl : (DeriveContext) fn(self : DeriveContext, trait_body : Expr) -> Expr

Parameters

NameTypeNotes
selfDeriveContextcomptime
trait_bodyExprcomptime

Returns: Expr

Result type-function
fn(OkType : Type, ErrorType : Type) -> Type

Result — a value that is either success (Ok) or failure (Err).

Result(OkType, ErrorType) has two variants:

  • .Ok(value) — contains a success value of type OkType
  • .Err(error) — contains an error value of type ErrorType

Example

(r : Result(i32, str)) = .Ok(i32(42));
assert(r.is_ok(), "expected Ok");

Type Parameters

NameTypeNotes
OkTypeTypecomptime
ErrorTypeTypecomptime

Trait Implementations

impl(generic(OkType : Type, ErrorType : Type), Result(OkType, ErrorType), ...)
unwrap : (fn(self : Self) -> OkType)

Extract the Ok value, panicking if Err.

Returns: OkType

unwrap_err : (fn(self : Self) -> ErrorType)

Extract the Err value, panicking if Ok.

Returns: ErrorType

is_ok : (fn(self : Self) -> bool)

Return true if the result is Ok.

Returns: bool

is_err : (fn(self : Self) -> bool)

Return true if the result is Err.

Returns: bool

impl(generic(OkType : Type, ErrorType : Type), Result(OkType, ErrorType), ...)
map : (fn(generic(B : Type), self : Self, f : Impl(Fn(a : OkType) -> B)) -> Result(B, ErrorType))

Map the Ok value with f, leaving Err untouched.

Returns: Result(B, ErrorType)

map_err : (fn(generic(F : Type), self : Self, f : Impl(Fn(a : ErrorType) -> F)) -> Result(OkType, F))

Map the Err value with f, leaving Ok untouched.

Returns: Result(OkType, F)

and_then : (fn(generic(B : Type), self : Self, f : Impl(Fn(a : OkType) -> Result(B, ErrorType))) -> Result(B, ErrorType))

Chain a computation that may fail on the Ok value.

Returns: Result(B, ErrorType)

or_else : (fn(generic(F : Type), self : Self, f : Impl(Fn(a : ErrorType) -> Result(OkType, F))) -> Result(OkType, F))

Chain a recovery computation on the Err value.

Returns: Result(OkType, F)

and : (fn(generic(B : Type), self : Self, res : Result(B, ErrorType)) -> Result(B, ErrorType))

Return res if Ok, otherwise propagate Err.

Returns: Result(B, ErrorType)

or : (fn(generic(F : Type), self : Self, res : Result(OkType, F)) -> Result(OkType, F))

Return self if Ok, otherwise return res.

Returns: Result(OkType, F)

ok : (fn(self : Self) -> Option(OkType))

Convert to Option(OkType), discarding the error.

Returns: Option(OkType)

err : (fn(self : Self) -> Option(ErrorType))

Convert to Option(ErrorType), discarding the success value.

Returns: Option(ErrorType)

map_or : (fn(generic(B : Type), self : Self, default_val : B, f : Impl(Fn(a : OkType) -> B)) -> B)

Apply f if Ok, otherwise return default_val.

Returns: B

map_or_else : (fn(generic(B : Type), self : Self, default_fn : Impl(Fn(a : ErrorType) -> B), f : Impl(Fn(a : OkType) -> B)) -> B)

Apply f if Ok, otherwise call default_fn with the error.

Returns: B

unwrap_or_else : (fn(self : Self, f : Impl(Fn(a : ErrorType) -> OkType)) -> OkType)

Extract the Ok value, or call f with the error to produce a fallback.

Returns: OkType

unwrap_or : (fn(self : Self, or_value : OkType) -> OkType)

Extract the Ok value, or return or_value if Err.

Returns: OkType

expect : (fn(self : Self, msg : str) -> OkType)

Extract the Ok value, panicking with msg if Err.

Returns: OkType

expect_err : (fn(self : Self, msg : str) -> ErrorType)

Extract the Err value, panicking with msg if Ok.

Returns: ErrorType

inspect : (fn(self : Self, f : Impl(Fn(a : OkType) -> unit)) -> Result(OkType, ErrorType))

Call f with the Ok value (if any), then return the result.

Returns: Result(OkType, ErrorType)

inspect_err : (fn(self : Self, f : Impl(Fn(a : ErrorType) -> unit)) -> Result(OkType, ErrorType))

Call f with the Err value (if any), then return the result.

Returns: Result(OkType, ErrorType)

impl(generic(OkType : Type, ErrorType : Type), where(OkType <: Default), Result(OkType, ErrorType), ...)
unwrap_or_default : (fn(self : Self) -> OkType)

Extract the contained value, or T's default when None.

Returns: OkType

impl(generic(T : Type, E : Type), Result(Result(T, E), E), ...)
flatten : (fn(self : Self) -> Result(T, E))

Collapse one level of nesting.

Returns: Result(T, E)

impl(generic(T : Type, E : Type), Result(Option(T), E), ...)
transpose : (fn(self : Self) -> Option(Result(T, E)))

Ok(Some(v)) becomes Some(Ok(v)), Ok(None) becomes None, Err(e) becomes Some(Err(e)).

Returns: Option(Result(T, E))

impl(generic(OkType : Type, ErrorType : Type), where(OkType <: Comptime, ErrorType <: Comptime), Result(OkType, ErrorType), Comptime())
impl(generic(OkType : Type, ErrorType : Type), where(OkType <: Comptime, ErrorType <: Comptime), Result(OkType, ErrorType), ...)
comptime_unwrap : (fn(comptime(self) : Self) -> comptime(OkType))

Compile-time unwrap — panics at compile-time if Err.

Returns: comptime(OkType)

comptime_unwrap_err : (fn(comptime(self) : Self) -> comptime(ErrorType))

Returns: comptime(ErrorType)

comptime_is_ok : (fn(comptime(self) : Self) -> comptime(bool))

Returns: comptime(bool)

comptime_is_err : (fn(comptime(self) : Self) -> comptime(bool))

Returns: comptime(bool)

impl(generic(T : Type, E : Type), where(T <: Clone, E <: Clone), Result(T, E), Clone(...))
clone : ( self -> match( self, .Ok(v) => Result(T, E).Ok(v.clone()), .Err(e) => Result(T, E).Err(e.clone()) ) )
impl(generic(T : Type, E : Type), where(T <: Copy, E <: Copy), Result(T, E), Copy())
impl(generic(T : Type, E : Type), where(T <: Eq(T), E <: Eq(E)), Result(T, E), Eq(Result(T, E)))
impl(generic(T : Type, E : Type), where(T <: Ord(T), E <: Ord(E)), Result(T, E), Ord(Result(T, E)))
impl(generic(T : Type, E : Type), where(T <: Hash, E <: Hash), Result(T, E), Hash(...))
hash : (fn(generic(H : Type), inout(self) : Self, inout(hasher) : H, where(H <: Hasher)) -> unit)

Feed this value's identity into hasher.

Parameters

NameTypeNotes
HType

Returns: unit

Box type-function
fn(V : Type) -> Type

Box(V): the old spelling of the shared, reference-counted cell, now Rc(V) (plans/VALUES_BY_DEFAULT.md §6 V1 step 1). Nothing in std, src or tests spells it. It stays defined for ONE seed only: the v0.2.54 seed compiles src/ against this std and still synthesizes box(...) when dyn(...) auto-boxes a payload that is not an object. Generation B part 2 deletes Box/box once SEED_VERSION carries Rc as the canonical cell, and V1 step 2 later reintroduces Box as the unique, uncounted cell.

Type Parameters

NameTypeNotes
VTypecomptime

Trait Implementations

impl(generic(T : Type), Box(T), Isolation(...))
can_isolate : (self -> (ref_count(self) == 1))
impl(generic(T : Type), where(T <: Hash), Box(T), Hash(...))
hash : (fn(generic(H : Type), inout(self) : Self, inout(hasher) : H, where(H <: Hasher)) -> unit)

Feed this value's identity into hasher.

Parameters

NameTypeNotes
HType

Returns: unit

impl(generic(T : Type), where(T <: Eq(T)), Box(T), Eq(Box(T)))
impl(generic(T : Type), where(T <: Clone), Box(T), Clone(...))
clone : (self -> box(self.*.clone()))
impl(generic(T : Type), where(T <: Default), Box(T), Default(...))
default : (fn() -> Self)

The default value of the type.

Returns: Self

impl(generic(T : Type), Box(T), Deref(...))
Target : T
Rc type-function
fn(V : Type) -> Type

Rc — a heap-allocated, reference-counted cell for a single value: the shared, counted cell's name under plans/VALUES_BY_DEFAULT.md (§3.2, decision 1). Copying a handle shares one heap value and bumps its count, as with Rust's Rc<T>; w.* names the payload, and w.field / w.method() reach it through auto-dereference (Deref).

Rc(V) is the canonical shared cell (V1 step 1, Generation B): the cell the compiler synthesizes (dyn(v) auto-boxes into rc(v)), and the one every std, src and test site spells. The legacy Box(V) above is a separate type with the same definition, kept for the seed only.

a := rc(i32(42));
b := a;          // a second handle to the same value
consume(b.* = i32(7));
assert(a.* == i32(7), "a and b name the same value");

Type Parameters

NameTypeNotes
VTypecomptime

Trait Implementations

impl(generic(T : Type), Rc(T), Isolation(...))
can_isolate : (self -> (ref_count(self) == 1))
impl(generic(T : Type), where(T <: Hash), Rc(T), Hash(...))
hash : (fn(generic(H : Type), inout(self) : Self, inout(hasher) : H, where(H <: Hasher)) -> unit)

Feed this value's identity into hasher.

Parameters

NameTypeNotes
HType

Returns: unit

impl(generic(T : Type), where(T <: Eq(T)), Rc(T), Eq(Rc(T)))
impl(generic(T : Type), where(T <: Clone), Rc(T), Clone(...))
clone : (self -> rc(self.*.clone()))
impl(generic(T : Type), where(T <: Default), Rc(T), Default(...))
default : (fn() -> Self)

The default value of the type.

Returns: Self

impl(generic(T : Type), Rc(T), Deref(...))
Target : T
Arc type-function
fn(V : Type) -> Type

=== Arc === Arc — an atomically reference-counted, thread-safe container for a single value.

Use arc(value) to allocate. Access the inner value with a.*.

Example

a := arc(i32(42));
assert(a.* == i32(42), "inner value is 42");

Type Parameters

NameTypeNotes
VTypecomptime

Trait Implementations

impl(generic(T : Type), where(T <: (Send, Sync, Acyclic)), Arc(T), Send())
impl(generic(T : Type), where(T <: (Send, Sync, Acyclic)), Arc(T), Sync())
impl(generic(T : Type), where(T <: (Send, Sync, Acyclic)), Arc(T), Deref(...))
Target : T
MaybeUninit type-function
fn(BaseType : Type) -> Type

MaybeUninit — a wrapper that allows holding an uninitialized value.

Useful for FFI or low-level patterns where a value must be allocated first and initialized later (e.g., by a C function). assume_init takes the as_ptr() result as a witness — a pointer only unsafe-capable code can hold — so safe code cannot read the uninitialized slot (issues/fixed/safe-code-reads-uninitialized-memory-through-maybeuninit-assume-init.md).

Example

extern(
  "C",
  time_t : Type,
  time : (fn(timer : ?*time_t) -> time_t)
);

uninitialized_timer := MaybeUninit(time_t).new();
ptr := uninitialized_timer.as_ptr();
time(.Some(ptr));
timer := uninitialized_timer.assume_init(ptr);

Type Parameters

NameTypeNotes
BaseTypeTypecomptime
impl(generic(BaseType : Type), MaybeUninit(BaseType), ...)
new : (fn() -> Self)

Create a new uninitialized value.

Returns: Self

as_ptr : (fn(inout(self) : Self) -> *BaseType)

Get a mutable pointer to the underlying value.

Returns: *BaseType

assume_init : (fn(own(self) : Self, written : *BaseType) -> BaseType)

Assume the value is initialized and extract it. Undefined behavior if not initialized. The written witness is the as_ptr() result you initialized through: a raw pointer only unsafe-capable code can hold, so safe code cannot reach the uninitialized read. It is not inspected.

Returns: BaseType

_probe : (fn(self : Self) -> i32)

Test-support probe for the member-visibility rule (E0405): a _-prefixed method declared in the PRELUDE is private to this module exactly like one declared in any other module (issues/fixed/prelude-methods-have-no-visibility-owner.md). It has no caller inside std/ — it exists so tests/member_visibility.test.yo can assert from a foreign directory that the compiler rejects the call.

Returns: i32

IterPair type-function
fn(A : Type, B : Type) -> Type

IterPair — a two-element product type used by enumerate and zip.

Type Parameters

NameTypeNotes
ATypecomptime
BTypecomptime
IterMap type-function
fn(I : Type, B : Type, F : Type) -> Type

Lazy iterator that maps each element through a function F.

Created by calling .map(f) on any iterator. I is the source iterator type, B is the output element type, F is the mapper closure type satisfying Fn(item : A) -> B.

Type Parameters

NameTypeNotes
ITypecomptime
BTypecomptime
FTypecomptime

Trait Implementations

impl(generic(I : Type, A : Type, B : Type, F : Type), where(I <: Iterator(Item := A), F <: (Fn(item : A) -> B)), IterMap(I, B, F), Iterator(...))
Item : B
next : (fn(inout(self) : Self) -> Option(B))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(B)

IterFilter type-function
fn(I : Type, F : Type) -> Type

Lazy iterator that skips elements for which the predicate returns false.

Created by calling .filter(pred) on any iterator. I is the source iterator type, F is the predicate closure type satisfying Fn(item : A) -> bool — by value, symmetric with map (plans/archive/STD_API_AUDIT.md D3.4's callback-asymmetry fix).

Type Parameters

NameTypeNotes
ITypecomptime
FTypecomptime

Trait Implementations

impl(generic(I : Type, A : Type, F : Type), where(I <: Iterator(Item := A), F <: (Fn(item : A) -> bool)), IterFilter(I, F), Iterator(...))
Item : A
next : (fn(inout(self) : Self) -> Option(A))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(A)

IterTake type-function
fn(I : Type) -> Type

Lazy iterator that yields at most n elements from the source.

Created by calling .take(n) on any iterator.

Type Parameters

NameTypeNotes
ITypecomptime

Trait Implementations

impl(generic(I : Type, A : Type), where(I <: Iterator(Item := A)), IterTake(I), Iterator(...))
Item : A
next : (fn(inout(self) : Self) -> Option(A))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(A)

IterSkip type-function
fn(I : Type) -> Type

Lazy iterator that skips the first n elements of the source, then yields all remaining elements.

Created by calling .skip(n) on any iterator.

Type Parameters

NameTypeNotes
ITypecomptime

Trait Implementations

impl(generic(I : Type, A : Type), where(I <: Iterator(Item := A)), IterSkip(I), Iterator(...))
Item : A
next : (fn(inout(self) : Self) -> Option(A))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(A)

IterEnumerate type-function
fn(I : Type) -> Type

Lazy iterator that pairs each element with its zero-based index.

Created by calling .enumerate() on any iterator. Yields IterPair(usize, A) values where _0 is the index and _1 is the original element.

Type Parameters

NameTypeNotes
ITypecomptime

Trait Implementations

impl(generic(I : Type, A : Type), where(I <: Iterator(Item := A)), IterEnumerate(I), Iterator(...))
Item : IterPair(usize, A)
next : (fn(inout(self) : Self) -> Option(IterPair(usize, A)))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(IterPair(usize, A))

IterZip type-function
fn(I : Type, J : Type) -> Type

Lazy iterator that combines two iterators element-by-element into pairs. Stops as soon as either iterator is exhausted.

Created by calling .zip(other) on any iterator. Yields IterPair(A, B) values.

Type Parameters

NameTypeNotes
ITypecomptime
JTypecomptime

Trait Implementations

impl(generic(I : Type, J : Type, A : Type, B : Type), where(I <: Iterator(Item := A), J <: Iterator(Item := B)), IterZip(I, J), Iterator(...))
Item : IterPair(A, B)
next : (fn(inout(self) : Self) -> Option(IterPair(A, B)))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(IterPair(A, B))

IterChain type-function
fn(I : Type, J : Type) -> Type

Lazy iterator that yields all of the first iterator, then all of the second.

Created by calling .chain(other) on any iterator. Both iterators must yield the same Item type.

Type Parameters

NameTypeNotes
ITypecomptime
JTypecomptime

Trait Implementations

impl(generic(I : Type, J : Type, A : Type), where(I <: Iterator(Item := A), J <: Iterator(Item := A)), IterChain(I, J), Iterator(...))
Item : A
next : (fn(inout(self) : Self) -> Option(A))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(A)

IterTakeWhile type-function
fn(I : Type, F : Type) -> Type

Lazy iterator that yields elements while pred holds, then stops forever.

Created by calling .take_while(pred) on any iterator.

Type Parameters

NameTypeNotes
ITypecomptime
FTypecomptime

Trait Implementations

impl(generic(I : Type, A : Type, F : Type), where(I <: Iterator(Item := A), F <: (Fn(item : A) -> bool)), IterTakeWhile(I, F), Iterator(...))
Item : A
next : (fn(inout(self) : Self) -> Option(A))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(A)

IterSkipWhile type-function
fn(I : Type, F : Type) -> Type

Lazy iterator that skips elements while pred holds, then yields the rest.

Created by calling .skip_while(pred) on any iterator.

Type Parameters

NameTypeNotes
ITypecomptime
FTypecomptime

Trait Implementations

impl(generic(I : Type, A : Type, F : Type), where(I <: Iterator(Item := A), F <: (Fn(item : A) -> bool)), IterSkipWhile(I, F), Iterator(...))
Item : A
next : (fn(inout(self) : Self) -> Option(A))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(A)

IterFilterMap type-function
fn(I : Type, B : Type, F : Type) -> Type

Lazy iterator that maps each element to an Option and yields the Somes.

Created by calling .filter_map(f) on any iterator. B is the output element type, F satisfies Fn(item : A) -> Option(B).

Type Parameters

NameTypeNotes
ITypecomptime
BTypecomptime
FTypecomptime

Trait Implementations

impl(generic(I : Type, A : Type, B : Type, F : Type), where(I <: Iterator(Item := A), F <: (Fn(item : A) -> Option(B))), IterFilterMap(I, B, F), Iterator(...))
Item : B
next : (fn(inout(self) : Self) -> Option(B))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(B)

IterPeekable type-function
fn(I : Type, A : Type) -> Type

Iterator wrapper that can look at the next element without consuming it.

Created by calling .peekable() on any iterator. A is the element type.

Type Parameters

NameTypeNotes
ITypecomptime
ATypecomptime

Trait Implementations

impl(generic(I : Type, A : Type), where(I <: Iterator(Item := A)), IterPeekable(I, A), ...)
peek : (fn(inout(self) : Self) -> Option(A))

Return the next element without consuming it. Repeated calls return the same element until next() is called.

Returns: Option(A)

impl(generic(I : Type, A : Type), where(I <: Iterator(Item := A)), IterPeekable(I, A), Iterator(...))
Item : A
next : (fn(inout(self) : Self) -> Option(A))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(A)

IterRev type-function
fn(I : Type) -> Type

Lazy iterator that yields the source's elements back-to-front.

Created by calling .rev() on any DoubleEndedIterator. next pulls from the source's BACK and next_back from its FRONT, so .rev().rev() restores the original order.

Type Parameters

NameTypeNotes
ITypecomptime

Trait Implementations

impl(generic(I : Type, A : Type), where(I <: DoubleEndedIterator(Item := A)), IterRev(I), Iterator(...))
Item : A
next : (fn(inout(self) : Self) -> Option(A))

Advance the iterator and return the next value, or None when exhausted.

Returns: Option(A)

impl(generic(I : Type, A : Type), where(I <: Iterator(Item := A)), IterRev(I), DoubleEndedIterator(...))
Item : A
next_back : (fn(inout(self) : Self) -> Option(A))

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Returns: Option(A)

FutureState

FutureState — the state of an async Future.

Variants

VariantFieldsDescription
Cold

The future is cold: created but not yet started (an io.async future before its first io.await / io.spawn). Was Pending until 2026-10-03; renamed because "pending" reads as Rust's "not ready yet", which every suspended future is (plans/ASYNC_IO_API_AUDIT.md Q4).

Running

The future has started and is not finished: suspended at an await, or an I/O operation in flight.

Completed

The future completed successfully.

Aborted

The future was aborted (e.g., via unwind).

Trait Implementations

impl(FutureState, Acyclic())
impl(FutureState, Runtime())
impl(FutureState, Send())
impl(FutureState, Sync())
impl(FutureState, Eq(FutureState))
Methods
clone : (FutureState) fn(inout(self) : FutureState) -> FutureState

Create an independent clone of self.

Parameters

NameTypeNotes
selfFutureState

Returns: FutureState

== : (FutureState) fn(lhs : FutureState, rhs : FutureState) -> bool

Parameters

NameTypeNotes
lhsFutureState
rhsFutureState

Returns: bool

!= : (FutureState) fn(lhs : FutureState, rhs : FutureState) -> bool

Parameters

NameTypeNotes
lhsFutureState
rhsFutureState

Returns: bool

JoinHandle type-function
fn(T : Type) -> Type

JoinHandle — a handle to a spawned async task. Generic over T, the return type of the spawned task.

The handle OWNS a reference to the task's future: the task (and its result) stay alive for as long as some copy of the handle does, and dropping the last copy releases it. A handle that is dropped without being awaited DETACHES the task — it keeps running and frees itself when it finishes — which is what makes a fire-and-forget io.spawn(…) statement correct (it used to leak the whole state machine, issues/fixed/statement-level-io-spawn-leaks-the-state-machine.md). Awaiting does not consume the handle; awaiting it twice reads the same result.

Type Parameters

NameTypeNotes
TTypecomptime

Trait Implementations

impl(generic(T : Type), JoinHandle(T), ...)
await : __yo_join_handle_await

Await a Future, suspending until its result is ready.

Returns: unknown

impl(generic(T : Type), JoinHandle(T), Dispose(...))
dispose : (fn(self : Self) -> unit)

Release the resources self owns — a file descriptor, a socket, a lock, a buffer the allocator handed out. Called automatically when the value's owner drops it (a value type) or the last reference to it goes away (a reference type), so an implementor never calls it directly and must tolerate being the only one who ever does.

It must be safe to run exactly once, and a type that also exposes an explicit close/release is responsible for making the second call a no-op.

Returns: unit

impl(generic(T : Type), JoinHandle(T), ...)
state : (fn(self : JoinHandle(T)) -> FutureState)

The task's current FutureState, read without blocking or driving the event loop (unlike await, which polls the loop to completion).

Returns: FutureState

as_ptr : (fn(self : JoinHandle(T)) -> *void)

The task's future as an untyped pointer, for the runtime externs that take a task (std/async's join waits, __yo_join_wait_add). The handle keeps owning its reference; the pointer is valid while some copy of the handle is alive. Reading through it is unsafe.

Returns: *void

is_finished : (fn(self : JoinHandle(T)) -> bool)

True once the task is terminal — Completed or Aborted.

Returns: bool

abort : (fn(self : JoinHandle(T)) -> unit)

Cancel the task: a non-terminal task is marked Aborted and will not resume past its current suspension point (its pending completion, if any, releases the state machine instead of resuming it). Completed and already-aborted tasks are left untouched. await on an aborted handle returns .None. An operation the task is suspended in is cancelled too where the I/O backend can take the registration back (timers and park futures on every backend; on Linux also the epoll and io_uring descriptor and datagram operations, on macOS the kqueue-parked descriptor operations): the task and what it was waiting on are then released at once instead of when that operation would have completed. An operation with no cancel path still runs to completion and releases the task then; the task stays Aborted. A child future the task is awaiting is aborted with it when the task started it (an anonymous io.await(child(io), io), or a named future this await cold-started); a named future someone else started may be shared and keeps running. A raw IoFuture spawned directly is cancelled the same way.

Returns: unit

Io struct
Io

Io module — the async runtime effect.

Provides io.async, io.await, io.spawn, and io.state operations. Automatically injected into main when declared with io : Io.

Fields

NameTypeDescription
asyncfn(generic(T, E) action : Impl(Fn(E) -> T)) -> Impl(Future(T, E))

Create a new Future from an async closure.

awaitfn(generic(T, E) fut : Impl(Future(T, E)), e : E) -> T

Await a Future, suspending until its result is ready.

statefn(generic(T, E) fut : Impl(Future(T, E))) -> FutureState

The task's current FutureState, read without blocking or driving the event loop (unlike await, which polls the loop to completion).

spawnfn(generic(T, E) fut : Impl(Future(T, E)), e : E) -> JoinHandle(T)

Spawn a Future as an independent task, returning a JoinHandle.

Traits / Modules

Comptime trait
Comptime

Comptime trait — indicates a type that can be used at compile-time. Examples: i32, bool, Type, comptime_int, comptime_float, comptime_str. Non-examples: int, ushort (runtime-only types).

Implementors

Runtime trait
Runtime

Runtime trait — indicates a type that can be used at runtime. Examples: i32, bool, *(i32), void. Non-examples: comptime_int, comptime_float, comptime_str, Type (compile-time-only types).

Implementors

Send trait
Send

Send trait — a value of this type may be MOVED to another thread.

The compiler derives it (plans/VALUES_BY_DEFAULT.md §3.8): a value is Send iff it reaches no non-atomic reference cell (Rc, Box, a ref(struct(...))), every component is Send, and it holds no raw pointer and no borrow. An atomic object is Send iff it is Sync, because its copies share one payload. Raw pointers are neither Send nor Sync unless a type opts in, with impl(T, Send()) under pragma(Pragma.AllowUnsafe).

Implementors

Sync trait
Sync

Sync trait — copies of a value of this type may be READ from several threads at once.

Derived like Send, over shared reads instead of a move: plain data, atomic cells (Arc, Atomic*, Mutex) and values composed of them are Sync; a non-atomic reference cell is not, and neither is a raw pointer unless a type opts in with impl(T, Sync()) under pragma(Pragma.AllowUnsafe). A closure is Sync iff its captured state is. Dyn(Trait) is Sync only as Dyn(Trait, Sync).

Implementors

MoveOnly trait
MoveOnly

MoveOnly trait - a value that cannot be copied, only moved.

A value type is move-only when it implements Dispose, when it declares impl(T, MoveOnly()), or when one of its fields, variant payloads, tuple or array elements, or closure captures is move-only. The compiler derives it; a declaration is needed only for a type that has no Dispose but must still never be duplicated (a token, a unique id).

A copy of a move-only value is a compile error (E0901). y := x moves x, and so do passing it to an own(...) parameter, storing it in a field or element, returning it and capturing it in a closure. A by-value parameter borrows it, so use_file(f) needs no move. Only a value type (struct, enum, newtype, and the tuples, arrays and closures built from them) can be move-only. A reference type (ref(struct(...)), Rc, Arc) is how a value is shared: its copies alias one cell, so it is never move-only, even around a move-only payload.

Dispose trait
Dispose

Dropping the last copy of the handle releases the task's future.

Methods

dispose : fn(self : Self) -> unit

Release the resources self owns — a file descriptor, a socket, a lock, a buffer the allocator handed out. Called automatically when the value's owner drops it (a value type) or the last reference to it goes away (a reference type), so an implementor never calls it directly and must tolerate being the only one who ever does.

It must be safe to run exactly once, and a type that also exposes an explicit close/release is responsible for making the second call a no-op.

Parameters

NameTypeNotes
selfSelf

Returns: unit

Implementors

Trace trait
Trace

Trace trait — mandatory for every reference type that can transitively hold a managed reference. Auto-derived by the compiler for structs/enums (incl. Option and all value types); hand-implemented for containers whose elements live in a heap buffer (ArrayList, HashMap, …). The constructor wires header.traverse_fn to this trace. Like Dispose, only a reference type may implement it (checked at the impl).

Methods

trace : fn(self : Self, tracer : GcTracer) -> unit

Parameters

NameTypeNotes
selfSelf
tracerGcTracer

Returns: unit

Implementors

Index trait-function
fn(Idx : Type) -> Type(1)

Index trait — enables container(idx) subscript syntax at runtime. The Idx parameter is the index type (e.g., usize, Range(usize)). Implementations must define an Output associated type and an index method.

Type Parameters

NameTypeNotes
IdxTypecomptime

Implementors

IndexUnchecked

IndexUnchecked — the bounds-check-free twin of Index(usize). Codegen calls index_unchecked instead of index ONLY at a subscript the verifier proved in bounds, in a verify-mode file (plans/backlog/SAFE_MODE_5B_CONTAINER_BOUNDS_ELISION.md). It returns a raw pointer, so safe code cannot call it. An impl's body must be its index body minus the length test: anything weaker turns a proof into undefined behavior.

Associated Types

NameConstraintDescription
OutputType

The output type of the addition.

Methods

index_unchecked : fn(inout(self) : Self, idx : usize) -> *(Output)

Parameters

NameTypeNotes
selfSelf
idxusize

Returns: *(Output)

Implementors

ComptimeIndex trait-function
fn(Idx : Type) -> Type(1)

ComptimeIndex — compile-time indexing trait for constant expressions.

Type Parameters

NameTypeNotes
IdxTypecomptime

Implementors

RangeOp trait
RangeOp

RangeOp trait — enables start..end operator syntax.

Methods

.. : fn(start : Self, end : Self) -> Range(Self)

Parameters

NameTypeNotes
startSelf
endSelf

Returns: Range(Self)

Implementors

RangeInclusiveOp

RangeInclusiveOp trait — enables start..=end operator syntax.

Methods

..= : fn(start : Self, end : Self) -> RangeInclusive(Self)

Parameters

NameTypeNotes
startSelf
endSelf

Returns: RangeInclusive(Self)

Implementors

ComptimeRangeOp

Methods

.. : fn(start : Self : (Comptime), end : Self) -> Range(Self : (Comptime))

Parameters

NameTypeNotes
startSelf : (Comptime)comptime
endSelf : (Comptime)comptime

Returns: Range(Self : (Comptime))

Implementors

ComptimeRangeInclusiveOp

Methods

..= : fn(start : Self : (Comptime), end : Self) -> RangeInclusive(Self : (Comptime))

Parameters

NameTypeNotes
startSelf : (Comptime)comptime
endSelf : (Comptime)comptime

Returns: RangeInclusive(Self : (Comptime))

Implementors

Add trait-function
fn(Rhs : Type) -> Type(1)

Add trait — enables lhs + rhs operator. Parameterized by Rhs type.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeAdd trait-function
fn(Rhs : Type) -> Type(1)

Compile-time variant of Add.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Sub trait-function
fn(Rhs : Type) -> Type(1)

Sub trait — enables lhs - rhs operator.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeSub trait-function
fn(Rhs : Type) -> Type(1)

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Mul trait-function
fn(Rhs : Type) -> Type(1)

Mul trait — enables lhs * rhs operator.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeMul trait-function
fn(Rhs : Type) -> Type(1)

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Div trait-function
fn(Rhs : Type) -> Type(1)

Div trait — enables lhs / rhs operator.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeDiv trait-function
fn(Rhs : Type) -> Type(1)

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Mod trait-function
fn(Rhs : Type) -> Type(1)

Mod trait — enables lhs % rhs operator.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeMod trait-function
fn(Rhs : Type) -> Type(1)

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

BitLeftShift trait-function
fn(Rhs : Type) -> Type(1)

BitLeftShift trait — enables lhs << rhs operator.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeBitLeftShift trait-function
fn(Rhs : Type) -> Type(1)

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

BitRightShift trait-function
fn(Rhs : Type) -> Type(1)

BitRightShift trait — enables lhs >> rhs operator.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeBitRightShift trait-function
fn(Rhs : Type) -> Type(1)

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Negate trait
Negate

Negate trait — enables unary -value operator.

Associated Types

NameConstraintDescription
OutputType

The output type of the addition.

Methods

neg : fn(self : Self) -> Output

Parameters

NameTypeNotes
selfSelf

Returns: Output

Implementors

ComptimeNegate

Associated Types

NameConstraintDescription
OutputType

The output type of the addition.

Methods

neg : fn(self : Self : (Comptime)) -> Output : (Comptime)

Parameters

NameTypeNotes
selfSelf : (Comptime)comptime

Returns: Output : (Comptime)

Implementors

LogicalNot trait
LogicalNot

LogicalNot trait — enables !value boolean negation.

Methods

! : fn(self : Self) -> bool

Parameters

NameTypeNotes
selfSelf

Returns: bool

Implementors

ComptimeLogicalNot

Methods

! : fn(self : Self : (Comptime)) -> bool

Parameters

NameTypeNotes
selfSelf : (Comptime)comptime

Returns: bool

Implementors

BitNot trait
BitNot

BitNot trait — enables ~value bitwise complement.

Associated Types

NameConstraintDescription
OutputType

The output type of the addition.

Methods

~ : fn(self : Self) -> Output

Parameters

NameTypeNotes
selfSelf

Returns: Output

Implementors

ComptimeBitNot

Associated Types

NameConstraintDescription
OutputType

The output type of the addition.

Methods

~ : fn(self : Self : (Comptime)) -> Output : (Comptime)

Parameters

NameTypeNotes
selfSelf : (Comptime)comptime

Returns: Output : (Comptime)

Implementors

BitAnd trait-function
fn(Rhs : Type) -> Type(1)

BitAnd trait — enables lhs & rhs bitwise AND.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeBitAnd trait-function
fn(Rhs : Type) -> Type(1)

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

BitOr trait-function
fn(Rhs : Type) -> Type(1)

BitOr trait — enables lhs | rhs bitwise OR.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeBitOr trait-function
fn(Rhs : Type) -> Type(1)

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

BitXor trait-function
fn(Rhs : Type) -> Type(1)

BitXor trait — enables lhs ^ rhs bitwise XOR.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeBitXor trait-function
fn(Rhs : Type) -> Type(1)

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Eq trait-function
fn(Rhs : Type) -> Type(1)

Eq trait — enables == and != comparison operators. The != method has a default implementation that negates ==.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeEq trait-function
fn(Rhs : Type) -> Type(1)

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Ord trait-function
fn(Rhs : Type) -> Type(1)

Ord trait — enables <, <=, >, >= comparison operators. Requires the type to also implement Eq.

cmp is contractually a TOTAL order for every std impl (the audit's no-PartialOrd decision, plans/archive/STD_API_AUDIT.md D3.3): the default is derived from </==, and types whose operators are only partial (floats: NaN is incomparable under IEEE <) OVERRIDE cmp with a total order instead of splitting the trait.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeOrd trait-function
fn(Rhs : Type) -> Type(1)

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Hasher trait
Hasher

Hasher — turns a stream of bytes into a u64 (Rust's std::hash::Hasher).

A Hash impl feeds a value's identity bytes to a hasher through the write* methods; finish reads the hash of everything written so far (it does not reset the hasher). write and finish are required; the fixed-width write_* methods default to the value's native-endian bytes, and an algorithm with a fast word path overrides them (std/hash's SipHasher13 overrides write_u64).

Implementations live in std/hash: SipHasher13 (keyed, the HashMap default), Fnv1aHasher, and the hash_one helper.

Methods

write : fn(inout(self) : Self, buf : *(u8), size : usize) -> unit

Feed size bytes starting at buf.

Parameters

NameTypeNotes
selfSelf
buf*(u8)
sizeusize

Returns: unit

finish : fn(inout(self) : Self) -> u64

The hash of everything written so far.

Parameters

NameTypeNotes
selfSelf

Returns: u64

write_u8 : fn(inout(self) : Self, v : u8) -> unit

Parameters

NameTypeNotes
selfSelf
vu8

Returns: unit

write_u16 : fn(inout(self) : Self, v : u16) -> unit

Parameters

NameTypeNotes
selfSelf
vu16

Returns: unit

write_u32 : fn(inout(self) : Self, v : u32) -> unit

Parameters

NameTypeNotes
selfSelf
vu32

Returns: unit

write_u64 : fn(inout(self) : Self, v : u64) -> unit

Parameters

NameTypeNotes
selfSelf
vu64

Returns: unit

write_usize : fn(inout(self) : Self, v : usize) -> unit

Parameters

NameTypeNotes
selfSelf
vusize

Returns: unit

write_i8 : fn(inout(self) : Self, v : i8) -> unit

Parameters

NameTypeNotes
selfSelf
vi8

Returns: unit

write_i16 : fn(inout(self) : Self, v : i16) -> unit

Parameters

NameTypeNotes
selfSelf
vi16

Returns: unit

write_i32 : fn(inout(self) : Self, v : i32) -> unit

Parameters

NameTypeNotes
selfSelf
vi32

Returns: unit

write_i64 : fn(inout(self) : Self, v : i64) -> unit

Parameters

NameTypeNotes
selfSelf
vi64

Returns: unit

write_isize : fn(inout(self) : Self, v : isize) -> unit

Parameters

NameTypeNotes
selfSelf
visize

Returns: unit

Implementors

Hash trait
Hash

Hash trait - Similar to Rust's std:#️⃣:Hash

A type says which bytes make up its identity by feeding them to a Hasher; the hasher (any Hasher, chosen by the caller) turns them into a u64. Types that implement Hash can be used as keys in HashMap and HashSet.

The contract, as in Rust:

  1. Consistent with Eq: if a == b, then a and b feed identical bytes.
  2. Prefix-free where it matters: variable-length data writes a length or a terminator (String writes its bytes then 0xFF), so ("ab","c") and ("a","bc") differ.

To hash a single value use std/hash's hash_one(value); to hash into a hasher you already hold, call value.hash(hasher).

Methods

hash : fn(generic(H) inout(self) : Self, inout(hasher) : H : (Hasher)) -> unit

Feed this value's identity into hasher.

Parameters

NameTypeNotes
selfSelf
hasherH : (Hasher)

Returns: unit

Implementors

Clone trait
Clone

Clone trait — deep-copy a value.

Methods

clone : fn(inout(self) : Self) -> Self

Create an independent clone of self.

Parameters

NameTypeNotes
selfSelf

Returns: Self

Implementors

Copy trait
Copy

Copy trait - a value whose copy is a bitwise copy (plans/VALUES_BY_DEFAULT.md decision 36).

Copy requires Clone, as Rust's Copy: Clone: the where(Self <: Clone) below makes every Copy impl need a Clone impl that covers the same instantiations, and makes where(T <: Copy) give T <: Clone in a generic body. The compiler never writes the Clone impl. A named type opts in with derive(T, Copy, Clone), and a generic one with derive(generic(T : Type), where(T <: Clone), Pair(T), Clone) beside impl(generic(T : Type), where(T <: Copy), Pair(T), Copy()) — the derive's clone calls .clone() on its fields, so it needs the bound. The impl is checked: every field, variant payload and element must be Copy, and the type must not implement Dispose (a copy would dispose twice) or declare MoveOnly. A hand-written Clone is an error only on a type that is Copy for every instantiation it serves: there clone() is the copy, so the derived, field-wise clone is the only spelling.

The integers, floats, bool, char and the C number types, unit, str views and raw pointers implement it here, each beside its Clone, and Option(T) and Result(T, E) do when their payloads do. A tuple, an Array(T, N), an anonymous record, a closure and a fn pointer have no declaration to annotate, so each is Copy, and Clone, when all its parts are. Box, Rc, Arc, String, the collections and Dyn never are.

Today every value type without an owned buffer is still copied implicitly, Copy or not. Generation B of decision 36 makes Copy the rule: a named type without it is then moved at its last use, and a later use is E0901.

Implementors

Default trait
Default

Default trait — the type's default value (Rust's Default). Call explicitly via (T <: Default).default() in generic code, or MyType.default() on a concrete type. Unblocks Option.unwrap_or_default and map or_default-style helpers (plans/archive/STD_API_AUDIT.md D3.1).

Methods

default : fn() -> Self

The default value of the type.

Returns: Self

Implementors

Isolation trait
Isolation

Isolation trait — runtime check whether a value can be safely transferred.

Methods

can_isolate : fn(self : Self) -> bool

Parameters

NameTypeNotes
selfSelf

Returns: bool

Implementors

ComptimeToString

ComptimeToString trait — compile-time string conversion.

Methods

to_comptime_string : fn(self : Self : (Comptime)) -> comptime_str

Render this type for DISPLAY — diagnostics, comptime_assert messages, generated comments.

NOT a source renderer: the result is not guaranteed to reparse. An instantiated generic has no written name to return, so it renders as a placeholder (<struct:struct_yo_id_5916>, <enum:enum_yo_id_3586>). Metaprogramming that needs to NAME a type in generated code must not use this — construct through Self, or reach the type as a value via Type.get_struct_fields(Self).get(i).field_type, which needs no name and no import at the use site.

Parameters

NameTypeNotes
selfSelf : (Comptime)comptime

Returns: comptime_str

Implementors

Integer trait
Integer

Integer — marker for the ten built-in integer types, so the arithmetic below can be written ONCE over T instead of ten times per method.

It exists because those bodies need T.MIN/T.MAX and ordering, which a where(T <: Integer) impl resolves through the type parameter. f32/f64 are deliberately NOT members: float arithmetic saturates to infinity rather than overflowing, so checked_* would be meaningless on them.

Implementors

SignedInteger

Marks the SIGNED integers. abs and signum exist only for them — Rust omits both on unsigned types, where abs would be the identity and signum could only ever answer 0 or 1. A marker trait is how a blanket impl gets restricted to half the integers, since where(T <: Integer) covers all ten.

Implementors

UnsignedCounterpart

The same-width UNSIGNED counterpart of a signed integer type.

An ASSOCIATED TYPE, which is the whole point: unsigned_abs needs to name "the unsigned type of the same width" in its RESULT position, and T.Unsigned is exactly that name. Without it the method would have to be written out once per signed type — five copies of one body, differing only in a cast.

Associated Types

NameConstraintDescription
UnsignedType

Implementors

ByteWidth trait
ByteWidth

The width in BYTES, as a TRAIT member so it can be read from a TYPE position — -> Array(u8, T.BYTES). BITS is an inherent associated constant and works in a VALUE position; an inherent constant does NOT resolve as an Array length, so this one is declared through a trait (issues/an-inherent-associated-constant-does-not-resolve-as-an-array-length.md).

Implementors

UnsignedInteger

Marks the UNSIGNED integers — the mirror of SignedInteger, and what restricts the power-of-two blanket below to the half of the integers Rust defines it on. is_power_of_two on a signed type would have to answer for negative receivers, and Rust simply does not offer it there.

Implementors

Deref trait
Deref

=== Deref === Deref — marks a wrapper whose members forward to its payload Target (auto-dereference, plans/VALUES_BY_DEFAULT.md §3.3). Nothing is called at run time: w.field and w.method() on a Deref type whose own members lack that name mean w.*.field and w.*.method(), recursively through nested wrappers. A name both have is E0616 (decision 32): Rc.clone(b) is the Rc's clone, b.*.clone() the payload's. w.* is the payload.

Implemented by Box, Rc and Arc only; any other impl(..., Deref(...)) is a compile error, so every auto-dereference goes through one of the prelude's cells.

P :: struct(n : i32);
b := rc(P(n : i32(1)));
b.n = i32(2);              // writes b.*.n
assert(b.n == i32(2), "read through the box");

Associated Types

NameConstraintDescription
TargetType

The payload type w.* names.

Implementors

Iterator trait
Iterator

Iterator trait — lazy, pull-based sequence traversal.

Associated Types

NameConstraintDescription
ItemType

The type of elements yielded — must equal Self's Iterator.Item.

Methods

next : fn(inout(self) : Self) -> Option(Item)

Advance the iterator and return the next value, or None when exhausted.

Parameters

NameTypeNotes
selfSelf

Returns: Option(Item)

Implementors

DoubleEndedIterator

DoubleEndedIterator trait — an Iterator that can also be advanced from the BACK. next and next_back consume from opposite ends of the same sequence and meet in the middle; once they meet, both return .None.

Declares its own Item, which is how next_back's signature can name it. It deliberately carries NO where-clause tying it to Iterator: a trait cannot constrain another trait's associated type to its OWN (where(Self <: Iterator(Item := Self.Item)) is rejected — the constraint value must be a type, not an associated-type projection of Self).

COHERENCE RULE (not compiler-checked): an impl's DoubleEndedIterator.Item MUST equal its Iterator.Item. The associated-type registry is keyed by (type id, label) with no trait discrimination and takes the FIRST match, so a mismatch is silently first-wins rather than diagnosed. Every impl in std pairs the two traits on the same type with the same Item.

Associated Types

NameConstraintDescription
ItemType

The type of elements yielded — must equal Self's Iterator.Item.

Methods

next_back : fn(inout(self) : Self) -> Option(Item)

Advance the iterator from the back and return the previous value, or None when the two ends have met.

Parameters

NameTypeNotes
selfSelf

Returns: Option(Item)

Implementors

IntoIterator trait
IntoIterator

IntoIterator trait — convert a collection into an iterator.

Associated Types

NameConstraintDescription
ItemType

The type of elements yielded — must equal Self's Iterator.Item.

IntoIterType

Methods

into_iter : fn(self : Self) -> IntoIter : (Iterator)

Parameters

NameTypeNotes
selfSelf

Returns: IntoIter : (Iterator)

Implementors

FromIterator trait
FromIterator

FromIterator trait — build Self from a sequence of Self.Elem values.

The iteration loop lives in the blanket collect below, not here, so this trait stays MONOMORPHIC: a seed constructor plus one element-at-a-time step, both statics, dispatched the way sum calls (A <: Default).default(). That is what removes the need for a trait method carrying its own generic(...) + where.

The element type is deliberately named Elem, NOT Item: the assoc-type registry is keyed by (type id, label) with no trait discrimination, so an Item here would collide with the collection's own IntoIterator.Item and resolve first-wins by load order — benign for ArrayList, but genuinely divergent for HashMap, whose IntoIterator.Item is MapEntry(K, V).

from_iter_add takes the accumulator by own and RETURNS it, so that one signature covers reference collections (mutate acc, return it — the return is a rebind of the same object) and value types such as String, whose write into a borrowed parameter would land in a copy (E0908).

Associated Types

NameConstraintDescription
ElemType

The element type this collection is built from.

Methods

from_iter_new : fn() -> Self

The empty collection collect starts from.

Returns: Self

from_iter_add : fn(sink(acc) : Self, item : Elem) -> Self

Add one element to a partially-built collection and return it.

Parameters

NameTypeNotes
accSelf
itemElem

Returns: Self

Implementors

From trait-function
fn(Source : Type) -> Type(1)

TryFrom trait — fallible conversion from one type to another. From trait — infallible conversion FROM another type (plans/archive/STD_API_AUDIT.md D3.2; the fallible pair is TryFrom below).

Type Parameters

NameTypeNotes
SourceTypecomptime

Implementors

Into trait-function
fn(To : Type) -> Type(1)

Into trait — infallible conversion of Self INTO another type. Called with the target type, mirroring try_into: wide := narrow.into(i64);

Type Parameters

NameTypeNotes
ToTypecomptime

Implementors

TryFrom trait-function
fn(Source : Type) -> Type(1)

Type Parameters

NameTypeNotes
SourceTypecomptime
TryInto trait-function
fn(To : Type) -> Type(1)

TryInto trait — fallible conversion of Self into another type.

Type Parameters

NameTypeNotes
ToTypecomptime

Functions

box function
fn(generic(V : Type), own(value) : V) -> Box(V)

Allocate a value on the heap, returning a Box(V).

Type Parameters

NameTypeNotes
VTypecomptime

Parameters

NameTypeNotes
valueV

Returns: Box(V)

rc function
fn(generic(V : Type), own(value) : V) -> Rc(V)

Allocate a value in a fresh reference-counted cell: rc(value) takes ownership of value and returns an Rc(V) whose ref_count is 1. rc is an ordinary function, not the count: the count is the ref_count(x) builtin (plans/VALUES_BY_DEFAULT.md decision 11).

a := rc(i32(42));
assert(ref_count(a) == usize(1), "a fresh cell has one owner");
b := a;
assert(b.* == i32(42), "a copy shares the cell");

Type Parameters

NameTypeNotes
VTypecomptime

Parameters

NameTypeNotes
valueV

Returns: Rc(V)

^ function
fn(v : Expr) -> Expr

Parameters

NameTypeNotes
vExprcomptime

Returns: Expr

arc function
fn(generic(V : Type), own(value) : V, where(V <: (Send, Sync, Acyclic))) -> Arc(V)

Allocate a value inside an Arc, returning an Arc(V).

Type Parameters

NameTypeNotes
VTypecomptime

Parameters

NameTypeNotes
valueV

Returns: Arc(V)

for function
fn(quote(coll) : Expr, quote(handle) : Expr) -> unquote(Expr)

for macro — iterate over a collection.

for(coll, x => body) — calls coll.into_iter() and binds x to each yielded value. The collection is moved into the iterator; object elements are handles, so mutating x in the body mutates the element in place.

for(coll, inout(x) => body) — the borrowed form (plans/archive/INOUT_LOCAL_BINDINGS_AUDIT.md §7): the collection is pinned by a hidden local, its runtime borrow flag is held for the whole loop, and each element is bound in place as an inout local through the pointer iterator iter() (no per-element dup; struct elements mutate in place). Any container operation that could invalidate an element (growth, shrink, removal) — reached through ANY handle — panics deterministically instead of leaving x dangling. Maps take for(map, (k, inout(v)) => body): the key by value, only the value borrowed, so a body can never rewrite a key in place. Value-type collections (Array(T, N)) and combinator chains have no iter(); use the value form.

Combinator chains (coll.into_iter().map(f), etc.) work transparently: a blanket into_iter impl on Iterator (below) makes every iterator its own IntoIterator.

Examples

// Object elements — mutate in place through the handle.
for(names, s => {
  s.push_str("!");
});

// Consume an iterator chain.
for(list.into_iter(), x => print(x));

// Borrow struct elements in place (read AND write).
for(enemies, inout(e) => {
  e.hp = (e.hp - i32(1));
});

Parameters

NameTypeNotes
collExpr
handleExpr

Returns: unquote(Expr)

Examples
// Object elements — mutate in place through the handle.
for(names, s => {
  s.push_str("!");
});

// Consume an iterator chain.
for(list.into_iter(), x => print(x));

// Borrow struct elements in place (read AND write).
for(enemies, inout(e) => {
  e.hp = (e.hp - i32(1));
});

Constants

unsafe constant module (drop : fn(value : Expr) -> Expr, cast : fn(generic(_Self) self : _Self, Target : Type) -> Target)

The unsafe module — provides low-level unwind hatches.

Value: source_namespace_9239973348331418852_0(drop: <fn(value)>, cast: <unknown: fn(generic(_Self) self : _Self, Target : Type) -> Target>)

not constant module (Call : Tuple(0 : fn(generic(_Self) self : _Self : (LogicalNot)) -> bool, 1 : fn(generic(_Self) self : _Self : (Comptime + ComptimeLogicalNot)) -> bool))

Value: source_namespace_9239973348331418852_1(Call: (<fn(self)>, <fn(self)>))

! constant module (Call : Tuple(0 : fn(generic(_Self) self : _Self : (LogicalNot)) -> bool, 1 : fn(generic(_Self) self : _Self : (Comptime + ComptimeLogicalNot)) -> bool))

Value: source_namespace_9239973348331418852_1(Call: (<fn(self)>, <fn(self)>))

~ constant module (Call : Tuple(0 : fn(generic(_Self) self : _Self : (BitNot)) -> _Self, 1 : fn(generic(_Self) self : _Self : (Comptime + ComptimeBitNot)) -> _Self))

Value: source_namespace_9239973348331418852_2(Call: (<fn(self)>, <fn(self)>))

- constant module (Call : Tuple(0 : fn(generic(_Self) self : _Self : (Negate)) -> _Self, 1 : fn(generic(_Self) self : _Self : (Comptime + ComptimeNegate)) -> _Self))

Value: source_namespace_9239973348331418852_3(Call: (<fn(self)>, <fn(self)>))

Var constant module (is_owning_the_rc_value : fn(variable : Expr) -> Expr, has_other_aliases : fn(variable : Expr) -> Expr)

Var — compile-time variable introspection utilities.

Provides macros for querying metadata about a variable at compile-time, such as ownership status and alias information.

Value: source_namespace_9239973348331418852_4(is_owning_the_rc_value: <fn(variable)>, has_other_aliases: <fn(variable)>)