Module 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, Drop,
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/archive/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
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
| Variant | Fields | Description |
|---|---|---|
AllowUnsafe | File is permitted to use raw pointer ops, | |
AllowMacroDef | File is permitted to DEFINE macro functions — | |
SkipPrelude | Disable the auto-import of | |
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 ( | |
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. |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
Methods
== : (Pragma) fn(lhs : &Pragma, rhs : &Pragma) -> bool!= : (Pragma) fn(lhs : &Pragma, rhs : &Pragma) -> boolThe functions behind an Allocator. Implementing one needs
pragma(Pragma.AllowUnsafe).
Allocator interface version 2, Zig's std.mem.Allocator calls:
alloc(ctx, size, align)returns a block of at leastsizebytes aligned toalign(a power of two, at least 16), or.None.realloc(ctx, ptr, old_size, new_size, align)resizes a block this vtable'sallocreturned forold_sizebytes atalign, keeping its firstmin(old_size, new_size)bytes..Noneleaves the original block untouched and still owned by the caller.free(ctx, ptr, size, align)releases such a block;sizeandalignare the ones it was allocated (or last reallocated) with, so a size-class allocator needs no header of its own.
A block can be freed on another thread (an Arc dropped elsewhere), so an
allocator shared across threads makes its free thread-safe. Codegen calls
these slots for the reference-counted objects an alloc argument places,
so the shape is a contract with the compiler: it reads the vtable's shape
to pick the runtime it emits (see std/allocator.yo's module notes).
Fields
| Name | Type | Description |
|---|---|---|
alloc | fn(ctx : ?(*(void)), size : usize, align : usize) -> ?(*(void)) | |
realloc | fn(ctx : ?(*(void)), ptr : ?(*(void)), old_size : usize, new_size : usize, align : usize) -> ?(*(void)) | |
free | fn(ctx : ?(*(void)), ptr : ?(*(void)), size : usize, align : usize) -> unit |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
Methods
clone : (AllocatorVTable) fn(self : &AllocatorVTable) -> AllocatorVTableCreate an independent clone of self.
Parameters
| Name | Type | Notes |
|---|---|---|
self | AllocatorVTable |
Returns: AllocatorVTable
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
| Name | Type | Description |
|---|---|---|
ctx | ?(*(void)) | |
vtable | *(AllocatorVTable) |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
impl(Allocator, Send())
impl(Allocator, Sync())
Methods
clone : (Allocator) fn(self : &Allocator) -> Allocatorglobal : (Allocator) fn() -> AllocatorReturns: Allocator
alloc : (Allocator) fn(self : Allocator, size : usize, align : usize) -> ?(*(void))realloc : (Allocator) fn(ptr : *(void), old_size : usize, new_size : usize, align : usize) -> ?(*(void))Parameters
| Name | Type | Notes |
|---|---|---|
ptr | *(void) | |
old_size | usize | |
new_size | usize | |
align | usize |
Returns: ?(*(void))
free : (Allocator) fn(ptr : ?(*(void)), size : usize, align : usize) -> unitParameters
| Name | Type | Notes |
|---|---|---|
ptr | ?(*(void)) | |
size | usize | |
align | usize |
Returns: unit
owner_of : (Allocator) fn(ptr : *(void)) -> Allocatorsame : (Allocator) fn(self : Allocator, other : Allocator) -> boolglobal : (Allocator) fn() -> AllocatorReturns: Allocator
alloc : (Allocator) fn(self : Allocator, size : usize, align : usize) -> ?(*(void))realloc : (Allocator) fn(ptr : *(void), old_size : usize, new_size : usize, align : usize) -> ?(*(void))Parameters
| Name | Type | Notes |
|---|---|---|
ptr | *(void) | |
old_size | usize | |
new_size | usize | |
align | usize |
Returns: ?(*(void))
free : (Allocator) fn(ptr : ?(*(void)), size : usize, align : usize) -> unitParameters
| Name | Type | Notes |
|---|---|---|
ptr | ?(*(void)) | |
size | usize | |
align | usize |
Returns: unit
owner_of : (Allocator) fn(ptr : *(void)) -> AllocatorHalf-open range start..end (excludes end).
Type Parameters
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
impl(Range(i8), Iterator(...))
Item : i8next : (fn(self : &mut Self) -> Option(i8))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(i8)
impl(Range(i16), Iterator(...))
Item : i16next : (fn(self : &mut Self) -> Option(i8))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(i8)
impl(Range(i32), Iterator(...))
Item : i32next : (fn(self : &mut Self) -> Option(i8))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(i8)
impl(Range(i64), Iterator(...))
Item : i64next : (fn(self : &mut Self) -> Option(i8))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(i8)
impl(Range(isize), Iterator(...))
Item : isizenext : (fn(self : &mut Self) -> Option(i8))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(i8)
impl(Range(u8), Iterator(...))
Item : u8next : (fn(self : &mut Self) -> Option(i8))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(i8)
impl(Range(u16), Iterator(...))
Item : u16next : (fn(self : &mut Self) -> Option(i8))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(i8)
impl(Range(u32), Iterator(...))
Item : u32next : (fn(self : &mut Self) -> Option(i8))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(i8)
impl(Range(u64), Iterator(...))
Item : u64next : (fn(self : &mut Self) -> Option(i8))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(i8)
impl(Range(usize), Iterator(...))
Item : usizenext : (fn(self : &mut Self) -> Option(i8))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(i8)
impl(Range(i8), DoubleEndedIterator(...))
Item : i8next_back : (fn(self : &mut 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 : i16next_back : (fn(self : &mut 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 : i32next_back : (fn(self : &mut 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 : i64next_back : (fn(self : &mut 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 : isizenext_back : (fn(self : &mut 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 : u8next_back : (fn(self : &mut 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 : u16next_back : (fn(self : &mut 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 : u32next_back : (fn(self : &mut 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 : u64next_back : (fn(self : &mut 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 : usizenext_back : (fn(self : &mut 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)
Inclusive range start..=end (includes end).
Type Parameters
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
impl(RangeInclusive(i8), Iterator(...))
Item : i8next : (fn(self : &mut Self) -> Option(i8))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(i8)
impl(RangeInclusive(i16), Iterator(...))
Item : i16next : (fn(self : &mut Self) -> Option(i8))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(i8)
impl(RangeInclusive(i32), Iterator(...))
Item : i32next : (fn(self : &mut Self) -> Option(i8))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(i8)
impl(RangeInclusive(i64), Iterator(...))
Item : i64next : (fn(self : &mut Self) -> Option(i8))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(i8)
impl(RangeInclusive(isize), Iterator(...))
Item : isizenext : (fn(self : &mut Self) -> Option(i8))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(i8)
impl(RangeInclusive(u8), Iterator(...))
Item : u8next : (fn(self : &mut Self) -> Option(i8))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(i8)
impl(RangeInclusive(u16), Iterator(...))
Item : u16next : (fn(self : &mut Self) -> Option(i8))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(i8)
impl(RangeInclusive(u32), Iterator(...))
Item : u32next : (fn(self : &mut Self) -> Option(i8))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(i8)
impl(RangeInclusive(u64), Iterator(...))
Item : u64next : (fn(self : &mut Self) -> Option(i8))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(i8)
impl(RangeInclusive(usize), Iterator(...))
Item : usizenext : (fn(self : &mut Self) -> Option(i8))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(i8)
impl(RangeInclusive(i8), DoubleEndedIterator(...))
Item : i8next_back : (fn(self : &mut 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 : i16next_back : (fn(self : &mut 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 : i32next_back : (fn(self : &mut 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 : i64next_back : (fn(self : &mut 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 : isizenext_back : (fn(self : &mut 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 : u8next_back : (fn(self : &mut 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 : u16next_back : (fn(self : &mut 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 : u32next_back : (fn(self : &mut 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 : u64next_back : (fn(self : &mut 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 : usizenext_back : (fn(self : &mut 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 — result of a comparison.
Variants
| Variant | Fields | Description |
|---|---|---|
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. |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
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
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
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))(...))
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
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
| Variant | Fields | Description |
|---|---|---|
Null | JSON | |
Bool | v: bool |
|
Int | v: comptime_int | An integer. JSON numbers that are whole become |
Float | v: comptime_float | A non-integral number. |
Str | v: comptime_str |
|
List | items: ComptimeList(ComptimeValue) | An array, in document order. |
Table | keys: ComptimeList(comptime_str), values: ComptimeList(ComptimeValue) | A table/object: |
Trait Implementations
impl(ComptimeValue, Comptime())
impl(ComptimeValue, ...)
get : (ComptimeValue) fn(self : ComptimeValue, key : comptime_str) -> ComptimeValueThe 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
| Name | Type | Notes |
|---|---|---|
self | ComptimeValue | comptime |
key | comptime_str | comptime |
Returns: ComptimeValue
at : (ComptimeValue) fn(self : ComptimeValue, i : usize) -> ComptimeValueThe element at i, or .Null when this is not a list or i is past its
end.
Parameters
| Name | Type | Notes |
|---|---|---|
self | ComptimeValue | comptime |
i | usize | comptime |
Returns: ComptimeValue
len : (ComptimeValue) fn(self : ComptimeValue) -> usizeThe number of elements of a list, or entries of a table; 0 otherwise.
Parameters
| Name | Type | Notes |
|---|---|---|
self | ComptimeValue | comptime |
Returns: usize
as_str : (ComptimeValue) fn(self : ComptimeValue, fallback : comptime_str) -> comptime_strThe string this holds, or fallback when it holds anything else.
Parameters
| Name | Type | Notes |
|---|---|---|
self | ComptimeValue | comptime |
fallback | comptime_str | comptime |
Returns: comptime_str
as_int : (ComptimeValue) fn(self : ComptimeValue, fallback : comptime_int) -> comptime_intThe integer this holds, or fallback when it holds anything else.
Parameters
| Name | Type | Notes |
|---|---|---|
self | ComptimeValue | comptime |
fallback | comptime_int | comptime |
Returns: comptime_int
as_bool : (ComptimeValue) fn(self : ComptimeValue, fallback : bool) -> boolThe boolean this holds, or fallback when it holds anything else.
Parameters
| Name | Type | Notes |
|---|---|---|
self | ComptimeValue | comptime |
fallback | bool | comptime |
Returns: bool
is_null : (ComptimeValue) fn(self : ComptimeValue) -> boolTrue when this is .Null — a missing key or an explicit JSON null.
Parameters
| Name | Type | Notes |
|---|---|---|
self | ComptimeValue | comptime |
Returns: bool
ExprList
Type reflection metadata structs — used by Type.get_info().
StructKind — discriminant for struct flavors.
Variants
| Variant | Fields | Description |
|---|---|---|
Struct | Regular value struct. | |
Object | Reference-counted object. | |
AtomicObject | Atomic reference-counted object. | |
NewType | Single-field newtype wrapper. |
Trait Implementations
impl(StructKind, Comptime())
TypeFieldInfo — metadata for a single struct/object field.
Fields
| Name | Type | Description |
|---|---|---|
name | comptime_str | Variant name. |
field_type | Type | Field type. |
Trait Implementations
impl(TypeFieldInfo, Comptime())
impl(TypeFieldInfo, ...)
to_expr : (TypeFieldInfo) fn(self : TypeFieldInfo) -> ExprConvert the field name to an AST expression (for metaprogramming).
Parameters
| Name | Type | Notes |
|---|---|---|
self | TypeFieldInfo | comptime |
Returns: Expr
ParamInfo — metadata for a function parameter.
Fields
| Name | Type | Description |
|---|---|---|
name | comptime_str | Variant name. |
param_type | Type | Parameter type. |
is_comptime | bool |
|
is_quote | bool |
|
is_variadic | bool |
|
Trait Implementations
impl(ParamInfo, Comptime())
FunctionInfo — metadata for a function type.
Fields
| Name | Type | Description |
|---|---|---|
params | ComptimeList(ParamInfo) | Regular parameters. |
return_type | Type | Return type. |
forall_params | ComptimeList(ForallParamInfo) | Optional generic parameters for generic types. |
implicit_params | ComptimeList(ImplicitParamInfo) | Implicit |
is_closure | bool |
|
Trait Implementations
impl(FunctionInfo, Comptime())
TraitKind — discriminant for different trait flavors.
Variants
| Variant | Fields | Description |
|---|---|---|
Future | child: Type, effects: ComptimeList(TraitInfo) | A Future trait with child type and effects. |
Fn | call: FunctionInfo | A callable |
Normal | A normal user-defined trait. |
Trait Implementations
impl(TraitKind, Comptime())
VariantInfo — metadata for an enum variant.
Fields
| Name | Type | Description |
|---|---|---|
name | comptime_str | Variant name. |
fields | ComptimeList(TypeFieldInfo) | Variant fields (may be empty for unit variants). |
_enum_type | Type | |
_variant_index | usize |
Trait Implementations
impl(VariantInfo, Comptime())
TypeInfo — compile-time enum representing rich type metadata.
Returned by Type.get_info() for compile-time type reflection.
Variants
| Variant | Fields | Description |
|---|---|---|
Unit | ||
Bool |
| |
Usize | ||
Isize | ||
U8 | ||
I8 | ||
U16 | ||
I16 | ||
U32 | ||
I32 | ||
U64 | ||
I64 | ||
F32 | ||
F64 | ||
Char | ||
Short | ||
UShort | ||
Int | An integer. JSON numbers that are whole become | |
UInt | ||
Long | ||
ULong | ||
LongLong | ||
ULongLong | ||
LongDouble | ||
Void | ||
Str |
| |
Array | element: Type, length: comptime_int | |
Tuple | fields: ComptimeList(TypeFieldInfo) | |
Struct | fields: ComptimeList(TypeFieldInfo), kind: StructKind | Regular value struct. |
Enum | variants: ComptimeList(VariantInfo) | |
Union | fields: ComptimeList(TypeFieldInfo) | |
Function | info: FunctionInfo | |
Ptr | pointee: Type | |
Dyn | required_traits: ComptimeList(TraitInfo), negative_traits: ComptimeList(TraitInfo) | |
Trait | fields: ComptimeList(TraitFieldInfo), kind: TraitKind | |
Type | level: comptime_int | |
Some | name: comptime_str, required_traits: ComptimeList(TraitInfo), negative_traits: ComptimeList(TraitInfo), resolved_type: Type | |
ComptimeInt | ||
ComptimeFloat | ||
ComptimeStr | ||
ComptimeList | element: Type | |
Expr | ||
TypeApplication | ||
Reference | pointee: Type, mutable: bool, origin: Type |
|
Origin | The |
Trait Implementations
impl(TypeInfo, Comptime())
impl(TypeInfo, ...)
is_struct : (TypeInfo) fn(self : TypeInfo) -> boolis_enum : (TypeInfo) fn(self : TypeInfo) -> boolis_union : (TypeInfo) fn(self : TypeInfo) -> boolis_tuple : (TypeInfo) fn(self : TypeInfo) -> boolis_array : (TypeInfo) fn(self : TypeInfo) -> boolis_str : (TypeInfo) fn(self : TypeInfo) -> boolis_function : (TypeInfo) fn(self : TypeInfo) -> boolis_pointer : (TypeInfo) fn(self : TypeInfo) -> boolis_trait : (TypeInfo) fn(self : TypeInfo) -> boolis_void : (TypeInfo) fn(self : TypeInfo) -> boolis_primitive : (TypeInfo) fn(self : TypeInfo) -> boolis_integer : (TypeInfo) fn(self : TypeInfo) -> boolis_float : (TypeInfo) fn(self : TypeInfo) -> boolis_comptime : (TypeInfo) fn(self : TypeInfo) -> booltrue if the parameter is compile-time (comptime).
Parameters
| Name | Type | Notes |
|---|---|---|
self | TypeInfo | comptime |
Returns: bool
is_numeric : (TypeInfo) fn(self : TypeInfo) -> boolFieldInfo — compile-time struct field metadata for derive rules (legacy alias).
Fields
| Name | Type | Description |
|---|---|---|
name | comptime_str | Variant name. |
field_type | Type | Field type. |
Trait Implementations
impl(FieldInfo, Comptime())
Option — a value that may or may not be present.
Option(T) has two variants:
.Some(value)— contains a value of typeT.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
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
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 : &mut Impl(FnMut(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 : &mut Impl(FnMut(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 : &mut Impl(FnMut(a : &T) -> bool)) -> Option(T))Return Some(value) if the predicate returns true, otherwise None.
Returns: Option(T)
or_else : (fn(self : Self, f : &mut Impl(FnMut() -> 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 : &mut Impl(FnMut(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 : &mut Impl(FnMut() -> B), f : &mut Impl(FnMut(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 : &mut Impl(FnMut() -> 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 : &mut Impl(FnMut(a : &T) -> bool)) -> bool)Return true if Some and the predicate holds for the value.
Returns: bool
inspect : (fn(self : Self, f : &mut Impl(FnMut(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(self : &mut Self) -> Option(T))Take the value out of the option, leaving None in its place.
Returns: Option(T)
replace : (fn(self : &mut 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)), ...)
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 : &mut Impl(FnMut() -> 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(...))
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), self : &Self, hasher : &mut H, where(H <: Hasher)) -> unit)Type Parameters
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
DeriveContext — context passed to derive rule functions (needs Option).
Used by the derive macro to generate trait implementations.
Fields
| Name | Type | Description |
|---|---|---|
target | Expr | The AST expression for the target type. |
forall_params | Option(Expr) | Optional generic parameters for generic types. |
where_clause | Option(Expr) | Optional where clause for constrained generics. |
Trait Implementations
impl(DeriveContext, Comptime())
impl(DeriveContext, ...)
make_impl : (DeriveContext) fn(self : DeriveContext, trait_body : Expr) -> ExprResult — a value that is either success (Ok) or failure (Err).
Result(OkType, ErrorType) has two variants:
.Ok(value)— contains a success value of typeOkType.Err(error)— contains an error value of typeErrorType
Example
(r : Result(i32, str)) = .Ok(i32(42));
assert(r.is_ok(), "expected Ok");
Type Parameters
| Name | Type | Notes |
|---|---|---|
OkType | Type | comptime |
ErrorType | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
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 : &mut Impl(FnMut(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 : &mut Impl(FnMut(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 : &mut Impl(FnMut(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 : &mut Impl(FnMut(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 : &mut Impl(FnMut(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 : &mut Impl(FnMut(a : &ErrorType) -> B), f : &mut Impl(FnMut(a : &OkType) -> B)) -> B)Apply f if Ok, otherwise call default_fn with the error.
Returns: B
unwrap_or_else : (fn(self : Self, f : &mut Impl(FnMut(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 : &mut Impl(FnMut(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 : &mut Impl(FnMut(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), ...)
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(...))
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), self : &Self, hasher : &mut H, where(H <: Hasher)) -> unit)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(T).new(v)), and the one
every std, src and test site spells. Its old name, Box, is free again:
V1 step 2 reintroduces Box as the unique, uncounted cell.
The payload is shared, so it is read-only through the handle, as Rust's
(decision 46): a write through the handle (h.* = v, h.field = v, a
&mut lend or a &mut self call on the payload) is E0919. A payload
several handles mutate is an Rc(RefCell(T)) (std/sync/refcell), and
Rc.make_mut / Rc.try_unwrap reach the payload of a handle that is the
only one.
The payload is Escapable (decision 43, plans/backlog/REFERENCES_AND_ORIGINS.md
O9): a type that holds a reference is E0909. The bound is kept until
origin propagation through counted cells; its collector reason went with
W6b (O9).
a := Rc.new(i32(42));
b := Rc.clone(a); // a second handle to the same value
assert(b.* == a.*, "a and b name the same value");
Type Parameters
| Name | Type | Notes |
|---|---|---|
V | ?(Sized) | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
impl(generic(V : Type), Rc(V), ...)
new : (fn(sink(value) : V, (alloc : Option(Allocator)) ?= .None, where(V <: Escapable)) -> Rc(V))Move value into a fresh reference-counted cell whose ref_count is 1.
alloc : .Some(a) places the cell in a; the default, .None, places
it on the global allocator. The last handle's drop frees the cell through
that allocator. Panics when the allocator is out of memory. As with
Box.new, the cell calls a's alloc directly.
a := Rc(i32).new(i32(42));
assert(ref_count(a) == usize(1), "a fresh cell has one owner");
Returns: Rc(V)
impl(generic(T : ?Sized), where(T <: Hash), Rc(T), Hash(...))
hash : (fn(generic(H : Type), self : &Self, hasher : &mut H, where(H <: Hasher)) -> unit)impl(generic(T : ?Sized), where(T <: Eq(T)), Rc(T), Eq(Rc(T)))
impl(generic(T : ?Sized), Rc(T), Clone(...))
clone : (fn(self : &Self) -> Self)Create an independent clone of self.
Returns: Self
impl(generic(T : ?Sized), Rc(T), ...)
as_ref : (fn(self : &Self) -> &T)Returns: &T
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), ...)
try_unwrap : (fn(sink(self) : Self) -> Result(T, Self))The payload by value when self is the only handle to its cell:
.Ok(payload), and the cell is freed. Otherwise .Err(self), the
handle back, unchanged. Rust's Rc::try_unwrap.
a := Rc.new(i32(5));
n := match(Rc.try_unwrap(a), .Ok(v) => v, .Err(_) => i32(0)); // the only handle: 5
Returns: Result(T, Self)
impl(generic(T : ?Sized), Rc(T), ...)
get_mut : (fn(self : &mut Self) -> Option(&mut T))The payload, written in place, when self is the only handle of
either kind to its cell: .Some of a &mut reference into the cell.
.None while another Rc or a Weak shares it, and nothing moves or
clones. Rust's Rc::get_mut (plans/VALUES_BY_DEFAULT.md decision 46's
door). The reference borrows self exclusively for as long as it
lives.
h := Rc.new(i32(1));
match(
Rc.get_mut(&mut h),
.Some(v) => {
v.* = i32(2);
},
.None => ()
);
assert(h.* == i32(2), "the only handle writes in place");
Returns: Option(&mut T)
_payload_mut : (fn(self : &mut Self) -> &mut T)The payload as a &mut place, for a caller that has proved self
unique (get_mut).
Returns: &mut T
impl(generic(T : Type), where(T <: Clone), Rc(T), ...)
make_mut : (fn(self : &mut Self) -> &mut T)The payload, written (a mutable projection), so the write never
reaches another handle. When another Rc shares the cell, self first
moves to a fresh cell holding a clone of the payload (the clone is
spelled in the name, §0.1 of the plan). When only Weak handles share
it, the payload itself moves to a fresh cell, with no clone, and the
old cell goes to the Weak handles, which upgrade to .None
afterwards. Rust's Rc::make_mut.
a := Rc.new(i32(1));
b := Rc.clone(a);
Rc.make_mut(&mut b) = i32(2); // b now has a cell of its own
assert(a.* == i32(1), "a is unchanged");
Returns: &mut T
impl(generic(T : ?Sized), Rc(T), ...)
downgrade : (fn(self : &Self) -> Weak(T))A Weak handle to self's cell: Rust's Rc::downgrade. Spelled
Rc.downgrade(&h), as Rc.try_unwrap is, so a payload method of the
same name stays reachable as h.downgrade().
Returns: Weak(T)
impl(generic(T : ?Sized), Rc(T), Deref(...))
Target : TWeak — a non-owning handle to an Rc cell: Rust's rc::Weak<T>
(plans/archive/WEAK_AND_UNCOLLECTED_RC.md §3). Rc.downgrade(&h) makes
one; w.upgrade() is .Some(handle), a new Rc to the same cell, while
any Rc to it is alive, and .None once the last one is dropped. A
Weak keeps the cell's bytes allocated, never its payload: the last Rc
drops the payload, and the last handle of either kind frees the cell.
A Weak is not an edge of the ownership graph, so a cycle closed through
one is not a cycle: a parent pointer is Weak(RefCell(Node)), and the
tree frees itself. It has no Deref: the payload may be gone, so
every read goes through upgrade. It is explicit-copy (Weak.clone(w)
makes a second handle) and never Send or Sync; ArcWeak is the
thread-safe form.
a := Rc.new(i32(7));
w := Rc.downgrade(&a);
assert(w.upgrade().unwrap().* == i32(7), "alive while a is");
consume(a);
assert(w.upgrade().is_none(), "the last Rc dropped the payload");
Type Parameters
| Name | Type | Notes |
|---|---|---|
V | ?(Sized) | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
impl(generic(T : Type), Weak(T), ...)
new : (fn() -> Self)A Weak that names no cell: upgrade is always .None. Rust's
Weak::new.
Returns: Self
impl(generic(T : ?Sized), Weak(T), ...)
upgrade : (fn(self : &Self) -> Option(Rc(T)))strong_count : (fn(self : &Self) -> usize)The number of Rc handles to the cell: 0 once the payload is gone,
and for Weak.new().
Returns: usize
weak_count : (fn(self : &Self) -> usize)The number of Weak handles to the cell, this one included: 0 once the
payload is gone (as Rust's), and for Weak.new(); usize.MAX when the
count saturated.
Returns: usize
ptr_eq : (fn(self : &Self, other : &Self) -> bool)Whether self and other name the same cell (two Weak.new() do).
Returns: bool
impl(generic(T : ?Sized), Weak(T), Clone(...))
clone : (fn(self : &Self) -> Self)Create an independent clone of self.
Returns: Self
impl(generic(T : Type), Weak(T), Default(...))
default : (fn() -> Self)The default value of the type.
Returns: Self
impl(generic(T : ?Sized), Weak(T), Drop(...))
drop : (fn(self : &mut Self) -> unit)One Weak fewer; the cell is freed when its payload is gone and this
was the last handle. A zeroed Weak (a task slot never stored) names
no cell, and dropping it is a no-op, as for Box.
Returns: unit
=== Box ===
Box — a uniquely owned heap cell for a single value, with no count: Rust's
Box<T> (plans/VALUES_BY_DEFAULT.md §3.2, V1 step 2). A recursive type
uses it (Expr :: enum(Num(i32), Add(Box(Self), Box(Self)))), and so does
a value that needs a stable address.
A Box has one owner. It is explicit-copy: a copy point moves it when it
is the box's last use, any other copy is E0901, and b.clone() is a deep
copy, a new cell holding a clone of the payload. Dropping the box drops its
payload and frees the cell. Box(T) is move-only when T is (no Clone).
w.* names the payload, and w.field / w.method() reach it through
auto-dereference (Deref). Sharing is Rc; a Box is never counted, so
ref_count rejects it.
The cell is the payload and nothing else: a global Box(T) allocates
exactly size_of(T) bytes, as Rust's does, and a zero-sized payload
allocates nothing. A cell placed by an alloc argument sits behind
Allocator.alloc's owner prefix (std/allocator.yo), which records the
allocator so the drop frees the cell through it, telling it the cell's
size and alignment. Whether the cell is placed is bit 0 of the handle's
cell pointer — free, because every cell is at least 16-byte aligned — so
the handle is one word and the cell carries no header. The cell pointer
is private: the payload's address is addr_of(b.*), never a cast of
the handle (plans/backlog/ALLOCATOR_PLACEMENT.md, "Related: Box's
layout").
V is ?Sized (plans/VALUES_BY_DEFAULT.md decision 49): Box([T]),
Box(str) and Box(Dyn(T)) are the one Box at an unsized payload, a
two-word handle whose second word is the payload's length or vtable.
new, into_inner and Default need a sized payload; the drop, Clone
(through CloneInto), allocator, as_ref and the trait impls do not.
a := Box.new(i32(41));
b := a.clone(); // an independent cell
b.* = i32(42);
assert(a.* == i32(41), "the clone is a new cell");
Type Parameters
| Name | Type | Notes |
|---|---|---|
V | ?(Sized) | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
impl(generic(T : Type), Box(T), ...)
new : (fn(value : T, (alloc : Option(Allocator)) ?= .None) -> Box(T))Move value into a new uniquely owned cell. alloc : .Some(a) places
the cell in a; the default, .None, places it on the global allocator.
The cell is freed through that allocator when the box is dropped. Panics
when the allocator is out of memory.
e := Box(i32).new(i32(1));
assert(e.* == i32(1), "the payload");
Returns: Box(T)
_align : (fn() -> usize)Returns: usize
into_inner : (fn(self : Self) -> T)Move the payload out and free the cell — Rust's *b move, or
Box::into_inner. The payload moves bitwise, so a move-only T works
(issues/fixed/2026-10-23-a-move-only-payload-cannot-move-out-of-a-box.md).
Returns: T
impl(generic(T : ?Sized), Box(T), ...)
_word : (fn(self : &Self) -> usize)Returns: usize
_is_placed : (fn(self : &Self) -> bool)Returns: bool
_payload : (fn(self : &Self) -> *T)Returns: *T
allocator : (fn(self : &Self) -> Option(Allocator))_free_cell : (fn(cell : *T, placed : bool) -> unit)Free a cell whose payload is already dropped or moved out: a placed one through the allocator its owner prefix records, telling it the block's size and alignment; a global one to the global heap. A global zero-sized payload owns no block.
Returns: unit
_free_consumed : (fn(self : Self) -> unit)Free the cell of a box whose payload a call has consumed: the release
after a Box(Dyn(FnOnce(...))) call (the call took the payload's
captures, or its call-once wrapper dropped them), so the payload is not
dropped again. The box is zeroed, as into_inner leaves it.
Returns: unit
impl(generic(T : ?Sized), Box(T), Drop(...))
drop : (fn(self : &mut Self) -> unit)Drops the payload, then frees the cell: a placed one through the allocator its owner prefix records, a global one to the global heap.
A zeroed box owns nothing, and dropping it is a no-op: codegen empties
a task's moved-from slots and leaves a slot its body never reached
zeroed, and drops both when the task is aborted, as every reference
handle's null-checked release allows. Without the check the abort of
a task that threw before a Box-holding local was stored freed an
address below null
(issues/fixed/2026-10-23-an-aborted-task-drops-a-box-local-it-never-stored.md).
Returns: unit
impl(generic(T : ?Sized), where(T <: CloneInto), Box(T), Clone(...))
clone : (fn(self : &Self) -> Self)Create an independent clone of self.
Returns: Self
impl(generic(T : ?Sized), where(T <: Hash), Box(T), Hash(...))
hash : (fn(generic(H : Type), self : &Self, hasher : &mut H, where(H <: Hasher)) -> unit)impl(generic(T : ?Sized), where(T <: Eq(T)), Box(T), Eq(Box(T)))
impl(generic(T : Type), where(T <: Default), Box(T), Default(...))
default : (fn() -> Self)The default value of the type.
Returns: Self
impl(generic(T : ?Sized), Box(T), ...)
as_ref : (fn(self : &Self) -> &T)Returns: &T
impl(generic(T : ?Sized), where(T <: Send), Box(T), Send())
impl(generic(T : ?Sized), where(T <: Sync), Box(T), Sync())
impl(generic(T : ?Sized), Box(T), Deref(...))
Target : T=== Arc === Arc — an atomically reference-counted, thread-safe container for a single value.
Use Arc.new(value) to allocate. Access the inner value with a.*.
The payload must be Send and Sync, as Rust's Arc<T> requires, and
Escapable: kept until origin propagation through counted cells; its
collector reason went with W6b (O9). A cycle of Arc handles leaks,
as in Rust: break it by clearing a back edge before the last handle that
reaches it is dropped. --allocator fixed --debug-heap counts the leaked
cells at exit.
Example
a := Arc.new(i32(42));
assert(a.* == i32(42), "inner value is 42");
Type Parameters
| Name | Type | Notes |
|---|---|---|
V | ?(Sized) | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
impl(generic(V : Type), Arc(V), ...)
new : (fn(sink(value) : V, (alloc : Option(Allocator)) ?= .None, where(V <: (Send, Sync, Escapable))) -> Arc(V))Move value into a new atomically counted cell, returning a handle
whose ref_count is 1. alloc : .Some(a) places the cell in a; the
default, .None, places it on the global allocator. The last handle's
drop, on whichever thread, frees the cell through that allocator. Panics
when the allocator is out of memory. As with Box.new, the cell calls
a's alloc directly.
a := Arc(i32).new(i32(42));
assert(a.* == i32(42), "the payload");
Returns: Arc(V)
impl(generic(T : ?Sized), where(T <: (Send, Sync)), Arc(T), Send())
impl(generic(T : ?Sized), where(T <: (Send, Sync)), Arc(T), Sync())
impl(generic(T : ?Sized), where(T <: (Send, Sync)), Arc(T), Clone(...))
clone : (fn(self : &Self) -> Self)Create an independent clone of self.
Returns: Self
impl(generic(T : ?Sized), where(T <: (Send, Sync)), Arc(T), ...)
as_ref : (fn(self : &Self) -> &T)Returns: &T
impl(generic(T : Type), where(T <: (Send, Sync)), Arc(T), ...)
try_unwrap : (fn(sink(self) : Self) -> Result(T, Self))The payload by value when self is the only Arc to its cell, else
.Err(self). ArcWeak handles to the cell upgrade to .None
afterwards. Rust's Arc::try_unwrap.
Returns: Result(T, Self)
impl(generic(T : ?Sized), where(T <: (Send, Sync)), Arc(T), ...)
get_mut : (fn(self : &mut Self) -> Option(&mut T))The payload, written in place, when self is the only handle of
either kind to its cell on any thread: .Some of a &mut reference
into the cell. .None while another Arc or an ArcWeak shares it,
and nothing moves or clones. Rust's Arc::get_mut.
The uniqueness lock makes "no ArcWeak" stable while the strong count
is read, as make_mut takes it: after the unlock no other strong
handle can be made, because self, the only one, is lent exclusively
for as long as the result lives.
Returns: Option(&mut T)
_payload_mut : (fn(self : &mut Self) -> &mut T)The payload as a &mut place, for a caller that has proved self
unique (get_mut).
Returns: &mut T
impl(generic(T : Type), where(T <: (Send, Sync, Clone)), Arc(T), ...)
make_mut : (fn(self : &mut Self) -> &mut T)The payload, written, so the write never reaches another handle. When
another Arc shares the cell, self first moves to a fresh cell
holding a clone of the payload. When only ArcWeak handles share it,
the payload itself moves to a fresh cell, with no clone, and the old
cell goes to the ArcWeak handles, which upgrade to .None afterwards.
Rust's Arc::make_mut.
Returns: &mut T
impl(generic(T : ?Sized), where(T <: (Send, Sync)), Arc(T), ...)
downgrade : (fn(self : &Self) -> ArcWeak(T))An ArcWeak handle to self's cell: Rust's Arc::downgrade. Spelled
Arc.downgrade(&h), as Arc.try_unwrap is.
Returns: ArcWeak(T)
impl(generic(T : ?Sized), where(T <: (Send, Sync)), Arc(T), Deref(...))
Target : TArcWeak — a non-owning handle to an Arc cell: Rust's sync::Weak<T>
(plans/archive/WEAK_AND_UNCOLLECTED_RC.md §3). Weak(T)'s thread-safe
twin: Arc.downgrade(&h) makes one, w.upgrade() is .Some(handle), a
new Arc to the same cell, while any Arc to it is alive on any thread,
and .None once the last one is dropped. The counts are atomic, so the
handle is Send and Sync (the payload of an Arc is both). A cycle of
Arc handles closed through an ArcWeak is not a leak.
a := Arc.new(i32(7));
w := Arc.downgrade(&a);
assert(w.upgrade().unwrap().* == i32(7), "alive while a is");
consume(a);
assert(w.upgrade().is_none(), "the last Arc dropped the payload");
Type Parameters
| Name | Type | Notes |
|---|---|---|
V | ?(Sized) | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
impl(generic(T : ?Sized), where(T <: (Send, Sync)), ArcWeak(T), Send())
impl(generic(T : ?Sized), where(T <: (Send, Sync)), ArcWeak(T), Sync())
impl(generic(T : Type), where(T <: (Send, Sync)), ArcWeak(T), ...)
new : (fn() -> Self)An ArcWeak that names no cell: upgrade is always .None.
Returns: Self
impl(generic(T : ?Sized), where(T <: (Send, Sync)), ArcWeak(T), ...)
upgrade : (fn(self : &Self) -> Option(Arc(T)))strong_count : (fn(self : &Self) -> usize)The number of Arc handles to the cell: 0 once the payload is gone,
and for ArcWeak.new(). Another thread may change it at any time.
Returns: usize
weak_count : (fn(self : &Self) -> usize)The number of ArcWeak handles to the cell, this one included: 0 once
the payload is gone, and for ArcWeak.new(); usize.MAX when the count
saturated. Another thread may change it at any time.
Returns: usize
ptr_eq : (fn(self : &Self, other : &Self) -> bool)Whether self and other name the same cell (two ArcWeak.new() do).
Returns: bool
impl(generic(T : ?Sized), where(T <: (Send, Sync)), ArcWeak(T), Clone(...))
clone : (fn(self : &Self) -> Self)Create an independent clone of self.
Returns: Self
impl(generic(T : Type), where(T <: (Send, Sync)), ArcWeak(T), Default(...))
default : (fn() -> Self)The default value of the type.
Returns: Self
impl(generic(T : ?Sized), where(T <: (Send, Sync)), ArcWeak(T), Drop(...))
drop : (fn(self : &mut Self) -> unit)One ArcWeak fewer; the cell is freed when its payload is gone and
this was the last handle. A zeroed handle names no cell.
Returns: unit
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);
The payload field _value is private to the prelude (E0405 elsewhere),
and MaybeUninit(T) is Clone and Copy only for a Copy payload, as
Rust's impl<T: Copy> Clone for MaybeUninit<T>. The clone is the
bitwise copy, never T's clone: of an unwritten Box or String that
would run on zeroed bytes
(issues/fixed/2026-11-11-safe-code-reads-maybeuninits-public-value-field-before-anything-was-written.md).
Type Parameters
| Name | Type | Notes |
|---|---|---|
BaseType | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
impl(generic(T : Type), where(T <: Copy), MaybeUninit(T), Clone(...))
clone : (fn(self : &Self) -> Self)Create an independent clone of self.
Returns: Self
impl(generic(BaseType : Type), MaybeUninit(BaseType), ...)
new : (fn() -> Self)Create a new uninitialized value.
Returns: Self
as_ptr : (fn(self : &mut Self) -> *BaseType)Get a mutable pointer to the underlying value.
Returns: *BaseType
assume_init : (fn(sink(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 — a two-element product type used by enumerate and zip.
Type Parameters
| Name | Type | Notes |
|---|---|---|
A | Type | comptime |
B | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
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
| Name | Type | Notes |
|---|---|---|
I | Type | comptime |
B | Type | comptime |
F | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
impl(generic(I : Type, A : Type, B : Type, F : Type), where(I <: Iterator(Item := A), F <: (FnMut(item : &A) -> B)), IterMap(I, B, F), Iterator(...))
Item : Bnext : (fn(self : &mut Self) -> Option(B))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(B)
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
| Name | Type | Notes |
|---|---|---|
I | Type | comptime |
F | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
impl(generic(I : Type, A : Type, F : Type), where(I <: Iterator(Item := A), F <: (FnMut(item : &A) -> bool)), IterFilter(I, F), Iterator(...))
Item : Anext : (fn(self : &mut Self) -> Option(A))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(A)
Lazy iterator that yields at most n elements from the source.
Created by calling .take(n) on any iterator.
Type Parameters
| Name | Type | Notes |
|---|---|---|
I | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
impl(generic(I : Type, A : Type), where(I <: Iterator(Item := A)), IterTake(I), Iterator(...))
Item : Anext : (fn(self : &mut Self) -> Option(A))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(A)
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
| Name | Type | Notes |
|---|---|---|
I | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
impl(generic(I : Type, A : Type), where(I <: Iterator(Item := A)), IterSkip(I), Iterator(...))
Item : Anext : (fn(self : &mut Self) -> Option(A))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(A)
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
| Name | Type | Notes |
|---|---|---|
I | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
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
| Name | Type | Notes |
|---|---|---|
I | Type | comptime |
J | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
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)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
| Name | Type | Notes |
|---|---|---|
I | Type | comptime |
J | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
impl(generic(I : Type, J : Type, A : Type), where(I <: Iterator(Item := A), J <: Iterator(Item := A)), IterChain(I, J), Iterator(...))
Item : Anext : (fn(self : &mut Self) -> Option(A))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(A)
Lazy iterator that yields elements while pred holds, then stops forever.
Created by calling .take_while(pred) on any iterator.
Type Parameters
| Name | Type | Notes |
|---|---|---|
I | Type | comptime |
F | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
impl(generic(I : Type, A : Type, F : Type), where(I <: Iterator(Item := A), F <: (FnMut(item : &A) -> bool)), IterTakeWhile(I, F), Iterator(...))
Item : Anext : (fn(self : &mut Self) -> Option(A))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(A)
Lazy iterator that skips elements while pred holds, then yields the rest.
Created by calling .skip_while(pred) on any iterator.
Type Parameters
| Name | Type | Notes |
|---|---|---|
I | Type | comptime |
F | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
impl(generic(I : Type, A : Type, F : Type), where(I <: Iterator(Item := A), F <: (FnMut(item : &A) -> bool)), IterSkipWhile(I, F), Iterator(...))
Item : Anext : (fn(self : &mut Self) -> Option(A))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(A)
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
| Name | Type | Notes |
|---|---|---|
I | Type | comptime |
B | Type | comptime |
F | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
impl(generic(I : Type, A : Type, B : Type, F : Type), where(I <: Iterator(Item := A), F <: (FnMut(item : &A) -> Option(B))), IterFilterMap(I, B, F), Iterator(...))
Item : Bnext : (fn(self : &mut Self) -> Option(B))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(B)
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
| Name | Type | Notes |
|---|---|---|
I | Type | comptime |
A | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
impl(generic(I : Type, A : Type), where(I <: Iterator(Item := A)), IterPeekable(I, A), ...)
peek : (fn(self : &mut Self) -> Option(A))Return the next element without consuming it. Repeated calls return
the same element until next() is called. The element is copied out,
so A is Copy; peek_cloned clones one that is not.
Returns: Option(A)
peek_cloned : (fn(self : &mut Self, where(A <: Clone)) -> Option(A))peek for an element that is not Copy: a clone of the next element.
Returns: Option(A)
impl(generic(I : Type, A : Type), where(I <: Iterator(Item := A)), IterPeekable(I, A), Iterator(...))
Item : Anext : (fn(self : &mut Self) -> Option(A))Advance the iterator and return the next value, or None when exhausted.
Returns: Option(A)
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
| Name | Type | Notes |
|---|---|---|
I | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
impl(generic(I : Type, A : Type), where(I <: DoubleEndedIterator(Item := A)), IterRev(I), Iterator(...))
Item : Anext : (fn(self : &mut 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 : Anext_back : (fn(self : &mut 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 — the state of an async Future.
Variants
| Variant | Fields | Description |
|---|---|---|
Cold | The future is cold: created but not yet started (an | |
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 |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
impl(FutureState, Runtime())
impl(FutureState, Send())
impl(FutureState, Sync())
impl(FutureState, Eq(FutureState))
Methods
clone : (FutureState) fn(self : &FutureState) -> FutureState== : (FutureState) fn(lhs : &FutureState, rhs : &FutureState) -> bool!= : (FutureState) fn(lhs : &FutureState, rhs : &FutureState) -> boolJoinHandle — a handle to a spawned async task.
Generic over T, the return type of the spawned task.
A move-only value (plans/VALUES_BY_DEFAULT.md §3.13 A3): the handle OWNS
one reference to the task's future, and its Drop releases it. It has
no Clone, so one task has one handle. Awaiting it (h.await(io),
io.await(h.join(io), io)) CONSUMES it: the result moves out of the task,
and a second await of the same handle is a use after move (E0901). A
result several tasks need is joined once and shared (Rc(T), a channel).
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
(issues/fixed/statement-level-io-spawn-leaks-the-state-machine.md).
Type Parameters
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
impl(generic(T : Type), JoinHandle(T), ...)
await : __yo_join_handle_awaitWait for the task and return its result, .None if it was aborted. It
consumes the handle: the result moves out of the task, and the handle's
reference is released. A BLOCKING poll of the event loop, for main and
plain functions; inside a task, io.await(h.join(io), io)
(std/async) suspends instead.
Returns: unknown
impl(generic(T : Type), JoinHandle(T), Drop(...))
drop : (fn(self : &mut Self) -> unit)One ArcWeak fewer; the cell is freed when its payload is gone and
this was the last handle. A zeroed handle names no cell.
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 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. The future the task is
awaiting is aborted with it: an await owns the future it consumed
(§3.13 A1), so nothing else can be holding it. A task the aborted one
was joining through a handle keeps running. A raw IoFuture spawned
directly is cancelled the same way.
Returns: unit
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
| Name | Type | Description |
|---|---|---|
async | fn(generic(T, E) action : Impl(FnOnce(E) -> T)) -> Impl(Future(T, E)) | Create a |
await | fn(generic(T, E) fut : Impl(Future(T, E)), e : E) -> T | Wait for the task and return its result, |
state | fn(generic(T, E) fut : &Impl(Future(T, E))) -> FutureState | The task's current |
spawn | fn(generic(T, E) fut : Impl(Future(T, E)), e : E) -> JoinHandle(T) | Spawn a |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
Traits / Modules
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 — 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 — 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, 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 — 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
Acyclic — a type whose values cannot reach a reference cycle: no cycle of
STRONG edges (Rc, Arc, a ref object) is reachable from T, and a
Weak/ArcWeak edge does not count (plans/archive/WEAK_AND_UNCOLLECTED_RC.md
§4). It is derived from the type's structure, like Escapable, and never
implemented by hand: a positive impl(T, Acyclic()) is an error, and
impl(T, !Acyclic) opts a type out. A where(T <: Acyclic) bound is how
an API promises its values cannot leak a cycle; nothing in std requires it.
Dropping the handle releases its reference to the task's future: an unawaited task is detached, and keeps running until it finishes.
Methods
drop : fn(self : &mut Self) -> unitOne ArcWeak fewer; the cell is freed when its payload is gone and
this was the last handle. A zeroed handle names no cell.
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self |
Returns: unit
Implementors
Index trait — enables container(idx) subscript syntax at runtime: a read
of container(idx) calls index, a read projection (decision 24) that
borrows the container shared. Every write through the subscript calls
IndexMut.index_mut instead (decision 34, V2b). The Idx parameter is
the index type (e.g., usize, String), taken BY VALUE as an operator
operand takes its operands (decision 34 as amended 2026-10-11).
Type Parameters
| Name | Type | Notes |
|---|---|---|
Idx | Type | comptime |
Implementors
IndexMut trait — the write half of Index: container(idx) = v, a field
or nested element of it, a &mut receiver or argument, addr_of. A type
with Index and no IndexMut has read-only elements. Its Output is
its Index's.
Type Parameters
| Name | Type | Notes |
|---|---|---|
Idx | Type | comptime |
Implementors
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/archive/SAFE_MODE_5B_CONTAINER_BOUNDS_ELISION.md). An impl's body
must be its index body minus the length test: anything weaker turns a
proof into undefined behavior. IndexUncheckedMut is the twin of
IndexMut(usize). Both return a raw pointer, so safe code cannot call them.
Associated Types
| Name | Constraint | Description |
|---|---|---|
Output | Type | The output type of the addition. |
Methods
index_unchecked : fn(self : &Self, idx : usize) -> *(Output)Implementors
ComptimeIndex — compile-time indexing trait for constant expressions.
Type Parameters
| Name | Type | Notes |
|---|---|---|
Idx | Type | comptime |
Implementors
Methods
..= : fn(start : Self : (Comptime), end : Self) -> RangeInclusive(Self : (Comptime))Parameters
| Name | Type | Notes |
|---|---|---|
start | Self : (Comptime) | comptime |
end | Self : (Comptime) | comptime |
Returns: RangeInclusive(Self : (Comptime))
Implementors
Negate trait — enables unary -value operator.
Associated Types
| Name | Constraint | Description |
|---|---|---|
Output | Type | The output type of the addition. |
Methods
neg : fn(self : Self) -> OutputImplementors
Associated Types
| Name | Constraint | Description |
|---|---|---|
Output | Type | The output type of the addition. |
Methods
neg : fn(self : Self : (Comptime)) -> Output : (Comptime)Implementors
BitNot trait — enables ~value bitwise complement.
Associated Types
| Name | Constraint | Description |
|---|---|---|
Output | Type | The output type of the addition. |
Methods
~ : fn(self : Self) -> OutputImplementors
Associated Types
| Name | Constraint | Description |
|---|---|---|
Output | Type | The output type of the addition. |
Methods
~ : fn(self : Self : (Comptime)) -> Output : (Comptime)Implementors
Eq trait — enables == and != comparison operators.
The != method has a default implementation that negates ==.
Type Parameters
| Name | Type | Notes |
|---|---|---|
Rhs | ?(Sized) | comptime |
Implementors
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
| Name | Type | Notes |
|---|---|---|
Rhs | ?(Sized) | comptime |
Implementors
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(self : &mut Self, buf : *(u8), size : usize) -> unitFeed size bytes starting at buf.
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
buf | *(u8) | |
size | usize |
Returns: unit
finish : fn(self : &Self) -> u64The hash of everything written so far.
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self |
Returns: u64
write_u8 : fn(self : &mut Self, v : u8) -> unitParameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
v | u8 |
Returns: unit
write_u16 : fn(self : &mut Self, v : u16) -> unitParameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
v | u16 |
Returns: unit
write_u32 : fn(self : &mut Self, v : u32) -> unitParameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
v | u32 |
Returns: unit
write_u64 : fn(self : &mut Self, v : u64) -> unitParameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
v | u64 |
Returns: unit
write_usize : fn(self : &mut Self, v : usize) -> unitParameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
v | usize |
Returns: unit
write_i8 : fn(self : &mut Self, v : i8) -> unitParameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
v | i8 |
Returns: unit
write_i16 : fn(self : &mut Self, v : i16) -> unitParameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
v | i16 |
Returns: unit
write_i32 : fn(self : &mut Self, v : i32) -> unitParameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
v | i32 |
Returns: unit
write_i64 : fn(self : &mut Self, v : i64) -> unitParameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
v | i64 |
Returns: unit
write_isize : fn(self : &mut Self, v : isize) -> unitParameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
v | isize |
Returns: unit
Implementors
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:
- Consistent with Eq: if a == b, then a and b feed identical bytes.
- 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) self : &Self, hasher : &mut H : (Hasher)) -> unitFeed this value's identity into hasher.
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
hasher | H : (Hasher) |
Returns: unit
Implementors
Clone trait — deep-copy a value.
Methods
clone : fn(self : &Self) -> SelfCreate an independent clone of self.
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self |
Returns: Self
Implementors
CloneInto trait — write an independent clone of self into the
uninitialized slot dst: Rust's CloneToUninit
(plans/VALUES_BY_DEFAULT.md decision 49). Self may be unsized, so this
is how Box(T).clone() and Rc.make_mut clone a payload whose size is
known only at run time: dst points at size_of_val(self) fresh bytes
(with self's length or vtable), and the clone is written there, never
dropping what dst held.
Every sized Clone type implements it through the prelude's blanket
impl; [T] does where T is Clone, and a Dyn whose trait list names
Clone does through its vtable.
Methods
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit
Implementors
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 Drop (a copy would dispose twice).
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. 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 — 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() -> SelfThe default value of the type.
Returns: Self
Implementors
ComptimeToString trait — compile-time string conversion.
Methods
to_comptime_string : fn(self : Self : (Comptime)) -> comptime_strRender 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
| Name | Type | Notes |
|---|---|---|
self | Self : (Comptime) | comptime |
Returns: comptime_str
Implementors
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
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
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
| Name | Constraint | Description |
|---|---|---|
Unsigned | Type |
Implementors
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
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 ===
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.new(P(n : i32(1)));
b.n = i32(2); // writes b.*.n
assert(b.n == i32(2), "read through the cell");
Associated Types
| Name | Constraint | Description |
|---|---|---|
Target | Type | The payload type |
Implementors
Iterator trait — lazy, pull-based sequence traversal.
Associated Types
| Name | Constraint | Description |
|---|---|---|
Item | Type | The type of elements yielded — must equal |
Methods
next : fn(self : &mut Self) -> Option(Item)Advance the iterator and return the next value, or None when exhausted.
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self |
Returns: Option(Item)
Implementors
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
| Name | Constraint | Description |
|---|---|---|
Item | Type | The type of elements yielded — must equal |
Methods
next_back : fn(self : &mut Self) -> Option(Item)Advance the iterator from the back and return the previous value, or
None when the two ends have met.
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self |
Returns: Option(Item)
Implementors
IntoIterator trait — convert a collection into an iterator that OWNS it.
into_iter takes its receiver by value (plans/VALUES_BY_DEFAULT.md
decision 39, V2b B7b): the iterator holds the collection, and the value
form for(coll, x => body) consumes coll. While a collection is still a
ref type, passing it by value shares it (a count bump), so a later use of
coll keeps working until that collection's flip; read a collection in
place with for(&coll, x => body), or iterate a copy,
coll.clone().into_iter().
Associated Types
| Name | Constraint | Description |
|---|---|---|
Item | Type | The type of elements yielded — must equal |
IntoIter | Type |
Methods
into_iter : fn(self : Self) -> IntoIter : (Iterator)Implementors
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
| Name | Constraint | Description |
|---|---|---|
Elem | Type | The element type this collection is built from. |
Methods
from_iter_new : fn() -> SelfThe empty collection collect starts from.
Returns: Self
from_iter_add : fn(acc : Self, item : &Elem) -> SelfAdd one element to a partially-built collection and return it.
Parameters
| Name | Type | Notes |
|---|---|---|
acc | Self | |
item | Elem |
Returns: Self
Implementors
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
| Name | Type | Notes |
|---|---|---|
Source | Type | comptime |
Implementors
TryInto trait — fallible conversion of Self into another type.
Type Parameters
| Name | Type | Notes |
|---|---|---|
To | Type | comptime |
Escapable trait — a value of this type carries no origin, so it may
outlive every place it was built from (decision 43,
plans/backlog/REFERENCES_AND_ORIGINS.md O10; Rust's T : 'static).
Derived structurally, never implemented by hand: a reference &T, a
type holding one (a field, an element, a payload, an origin argument),
a closure with a borrow capture and a borrowing future are not
Escapable; every other type is. The positions that outlive their
creator require it: an Rc/Arc payload, a module-level binding, an
extern signature. A generic function states it with
where(T <: Escapable), so a caller passing an origin-carrying type is
rejected at the call (E0909) instead of inside the specialization.
Sized trait — a type whose values have a size known at compile time
(plans/VALUES_BY_DEFAULT.md decision 49; Rust's Sized).
Derived structurally, never implemented by hand: every type is Sized
except [T] (Slice(T)), a type variable declared ?Sized and a struct
whose last field is unsized. An unsized type lives only behind a pointer
(&T, &mut T, *T). Every generic(T : Type) and comptime(V) : Type
binder carries where(T <: Sized) implicitly; generic(T : ?Sized) drops
it, and where(T <: Sized) restates it on one method of a ?Sized impl.
Functions
One ArcWeak fewer; the cell is freed when its payload is gone and
this was the last handle. A zeroed handle names no cell.
Type Parameters
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
Parameters
| Name | Type | Notes |
|---|---|---|
x | T |
Returns: unit
Run the destructor of the value p points at, in place: its Drop impl
and the release of everything it owns, without moving it out — Rust's
ptr::drop_in_place. The slot keeps its now-dead bytes, so the caller must
treat it as uninitialized: not read it, not drop it again, only overwrite
it (consume(p.* = v)) or free it. This is how a collection destroys an
element it owns through a raw pointer. Like every raw-pointer operation it
needs pragma(Pragma.AllowUnsafe); safe code ends a value with drop(x).
Type Parameters
| Name | Type | Notes |
|---|---|---|
T | ?Sized | comptime |
Parameters
| Name | Type | Notes |
|---|---|---|
p | *T |
Returns: unit
Constants
The unsafe module: one low-level escape hatch, cast (a reinterpret cast via __yo_as).
Value: source_namespace_9239973348331418852_0(cast: <unknown: fn(generic(_Self) self : &_Self, Target : Type) -> Target>)
Value: source_namespace_9239973348331418852_1(Call: (<fn(self)>, <fn(self)>))
Value: source_namespace_9239973348331418852_1(Call: (<fn(self)>, <fn(self)>))
Value: source_namespace_9239973348331418852_2(Call: (<fn(self)>, <fn(self)>))
Value: source_namespace_9239973348331418852_3(Call: (<fn(self)>, <fn(self)>))