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, Box,
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.
Types
Half-open range start..end (excludes end).
Type Parameters
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
Trait Implementations
impl(forall(T : Type), Range(T), Acyclic())
impl(forall(T : Type), where(T <: Comptime), Range(T), Comptime())
impl(forall(T : Type), where(T <: Runtime), Range(T), Runtime())
Inclusive range start..=end (includes end).
Type Parameters
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
Trait Implementations
impl(forall(T : Type), RangeInclusive(T), Acyclic())
impl(forall(T : Type), where(T <: Comptime), RangeInclusive(T), Comptime())
impl(forall(T : Type), where(T <: Runtime), RangeInclusive(T), Runtime())
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
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
str — an immutable UTF-8 byte string view (newtype over Slice(u8)).
String literals "hello" produce str at runtime.
For heap-allocated growable strings, see String.
Fields
| Name | Type | Description |
|---|---|---|
bytes | [u8] | The underlying byte slice. |
Trait Implementations
impl(str, ...)
from_raw_parts : (str) fn(ptr : *(u8), length : usize) -> strConstruct a str from a raw pointer and length.
Parameters
| Name | Type | Notes |
|---|---|---|
ptr | *(u8) | |
length | usize |
Returns: str
len : (str) fn(self : str) -> usizeReturn the length in bytes.
Parameters
| Name | Type | Notes |
|---|---|---|
self | str |
Returns: usize
ptr : (str) fn(self : str) -> *(u8)Parameters
| Name | Type | Notes |
|---|---|---|
self | str |
Returns: *(u8)
impl(str, Eq(str)(...))
impl(str, Ord(str)(...))
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_string | Variant name. |
field_type | Type | Field type. |
Trait Implementations
impl(TypeFieldInfo, Comptime())
impl(TypeFieldInfo, ...)
to_expr : (TypeFieldInfo) fn(comptime(self) : TypeFieldInfo) -> (comptime(fn_return_yocd6da6f3_id_20215) : Expr)Convert the field name to a quoted expression.
Parameters
| Name | Type | Notes |
|---|---|---|
self | TypeFieldInfo | comptime |
Returns: Expr
ParamInfo — metadata for a function parameter.
Fields
| Name | Type | Description |
|---|---|---|
name | comptime_string | 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 forall 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_string | 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 | ||
UInt | ||
Long | ||
ULong | ||
LongLong | ||
ULongLong | ||
LongDouble | ||
Void | ||
Array | element: Type, length: comptime_int | |
Slice | element: Type | |
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 | |
Iso | child: Type | |
Dyn | required_traits: ComptimeList(TraitInfo), negative_traits: ComptimeList(TraitInfo) | |
Module | fields: ComptimeList(TypeFieldInfo) | |
Trait | fields: ComptimeList(TraitFieldInfo), kind: TraitKind | |
Type | level: comptime_int | |
Some | name: comptime_string, required_traits: ComptimeList(TraitInfo), negative_traits: ComptimeList(TraitInfo), resolved_type: Type | |
ComptimeInt | ||
ComptimeFloat | ||
ComptimeString | ||
ComptimeList | element: Type | |
Expr | ||
EffectsRow | ||
TypeApplication |
Trait Implementations
impl(TypeInfo, Comptime())
impl(TypeInfo, ...)
is_struct : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20300) : bool)is_enum : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20303) : bool)is_union : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20306) : bool)is_tuple : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20309) : bool)is_array : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20312) : bool)is_slice : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20315) : bool)is_function : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20318) : bool)is_pointer : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20321) : bool)is_trait : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20324) : bool)is_module : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20327) : bool)is_void : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20330) : bool)is_primitive : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20333) : bool)is_integer : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20336) : bool)is_float : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20339) : bool)is_comptime : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20342) : bool)true if the parameter is compile-time (comptime).
Parameters
| Name | Type | Notes |
|---|---|---|
self | TypeInfo | comptime |
Returns: bool
is_numeric : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20345) : bool)FieldInfo — compile-time struct field metadata for derive rules (legacy alias).
Fields
| Name | Type | Description |
|---|---|---|
name | comptime_string | 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(forall(T : Type), Option(T), ...)
unwrap : (fn(self : Self) -> T)Extract the Ok value, panicking if Err.
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(forall(T : Type), Option(T), ...)
map : (fn(forall(B : Type), self : Self, f : Impl(Fn(a : T) -> B)) -> Option(B))Map the Ok value with f, leaving Err untouched.
Returns: Option(B)
and_then : (fn(forall(B : Type), self : Self, f : Impl(Fn(a : T) -> Option(B))) -> Option(B))Chain a computation that may fail on the Ok value.
Returns: Option(B)
filter : (fn(self : Self, predicate : Impl(Fn(a : T) -> bool)) -> Option(T))Return Some(value) if the predicate returns true, otherwise None.
Returns: Option(T)
or_else : (fn(self : Self, f : Impl(Fn() -> Option(T))) -> Option(T))Chain a recovery computation on the Err value.
Returns: Option(T)
map_or : (fn(forall(B : Type), self : Self, default_val : B, f : Impl(Fn(a : T) -> B)) -> B)Apply f if Ok, otherwise return default_val.
Returns: B
map_or_else : (fn(forall(B : Type), self : Self, default_fn : Impl(Fn() -> B), f : Impl(Fn(a : T) -> B)) -> B)Apply f if Ok, otherwise call default_fn with the error.
Returns: B
and : (fn(forall(B : Type), self : Self, optb : Option(B)) -> Option(B))Return res if Ok, otherwise propagate Err.
Returns: Option(B)
or : (fn(self : Self, optb : Option(T)) -> Option(T))Return self if Ok, otherwise return res.
Returns: Option(T)
unwrap_or_else : (fn(self : Self, f : Impl(Fn() -> T)) -> T)Extract the Ok value, or call f with the error to produce a fallback.
Returns: T
impl(forall(T : Type), Option(Option(T)), ...)
flatten : (fn(self : Self) -> Option(T))Collapse one level of nesting.
Returns: Option(T)
impl(forall(T : Type), where(T <: Comptime), Option(T), Comptime())
impl(forall(T : Type), where(T <: Comptime), Option(T), ...)
comptime_unwrap : (fn(comptime(self) : Self) -> comptime(T))Compile-time unwrap — panics at compile-time if Err.
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(forall(T : Type), Option(T), ...)
ok_or : (fn(forall(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(forall(E : Type), self : Self, err_fn : Impl(Fn() -> E)) -> Result(T, E))Convert Some(value) to Ok(value), or call err_fn to produce Err if None.
Returns: Result(T, E)
Type Parameters
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
Type Parameters
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
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 forall 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(comptime(self) : DeriveContext, comptime(trait_body) : Expr) -> (comptime(fn_return_yocd6da6f3_id_21037) : Expr)Result — 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(forall(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(forall(OkType : Type, ErrorType : Type), Result(OkType, ErrorType), ...)
map : (fn(forall(B : Type), self : Self, f : Impl(Fn(a : OkType) -> B)) -> Result(B, ErrorType))Map the Ok value with f, leaving Err untouched.
Returns: Result(B, ErrorType)
map_err : (fn(forall(F : Type), self : Self, f : Impl(Fn(a : ErrorType) -> F)) -> Result(OkType, F))Map the Err value with f, leaving Ok untouched.
Returns: Result(OkType, F)
and_then : (fn(forall(B : Type), self : Self, f : Impl(Fn(a : OkType) -> Result(B, ErrorType))) -> Result(B, ErrorType))Chain a computation that may fail on the Ok value.
Returns: Result(B, ErrorType)
or_else : (fn(forall(F : Type), self : Self, f : Impl(Fn(a : ErrorType) -> Result(OkType, F))) -> Result(OkType, F))Chain a recovery computation on the Err value.
Returns: Result(OkType, F)
and : (fn(forall(B : Type), self : Self, res : Result(B, ErrorType)) -> Result(B, ErrorType))Return res if Ok, otherwise propagate Err.
Returns: Result(B, ErrorType)
or : (fn(forall(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(forall(B : Type), self : Self, default_val : B, f : Impl(Fn(a : OkType) -> B)) -> B)Apply f if Ok, otherwise return default_val.
Returns: B
map_or_else : (fn(forall(B : Type), self : Self, default_fn : Impl(Fn(a : ErrorType) -> B), f : Impl(Fn(a : OkType) -> B)) -> B)Apply f if Ok, otherwise call default_fn with the error.
Returns: B
unwrap_or_else : (fn(self : Self, f : Impl(Fn(a : ErrorType) -> OkType)) -> OkType)Extract the Ok value, or call f with the error to produce a fallback.
Returns: OkType
impl(forall(OkType : Type, ErrorType : Type), where(OkType <: Comptime, ErrorType <: Comptime), Result(OkType, ErrorType), Comptime())
impl(forall(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)
Box — a heap-allocated, reference-counted container for a single value.
Use box(value) to allocate. Access the inner value with b.*.
Example
b := box(i32(42));
assert((b.* == i32(42)), "inner value is 42");
Type Parameters
| Name | Type | Notes |
|---|---|---|
V | Type | comptime |
Trait Implementations
impl(forall(T : Type), Box(T), Isolation(...))
can_isolate : ((self) -> (rc(self) == 1))impl(forall(T : Type), where(T <: Hash), Box(T), Hash(
(hash) : ((self) -> (self.*).*.hash())
))
impl(forall(T : Type), where(T <: Eq(T)), Box(T), Eq(Box(T)))
=== Arc === Arc — an atomically reference-counted, thread-safe container for a single value.
Use arc(value) to allocate. Access the inner value with a.*.
Example
a := arc(i32(42));
assert((a.* == i32(42)), "inner value is 42");
Type Parameters
| Name | Type | Notes |
|---|---|---|
V | Type | comptime |
Trait Implementations
impl(forall(T : Type), where(T <: (Send, Acyclic)), Arc(T), Send())
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).
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();
Type Parameters
| Name | Type | Notes |
|---|---|---|
BaseType | Type | comptime |
impl(forall(BaseType : Type), MaybeUninit(BaseType), ...)
new : (fn() -> Self)Create a new uninitialized value.
Returns: Self
as_ptr : (fn(self: *(Self)) -> *(BaseType))Get a mutable pointer to the underlying value.
Returns: *(BaseType)
assume_init : (fn(own(self) : Self) -> BaseType)Assume the value is initialized and extract it. Undefined behavior if not initialized.
Returns: BaseType
Pointer iterator for Array(T, N) - yields *(T) pointers to each element Used by Array.iter()
Type Parameters
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
Trait Implementations
impl(forall(T : Type), ArrayIterPtr(T), Iterator(...))
Item : *(T)next : (fn(self : *(Self)) -> Option(*(T)))Returns: Option(*(T))
Pointer iterator for Slice(T) - yields *(T) pointers to each element Used by Slice.iter()
Type Parameters
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
Trait Implementations
impl(forall(T : Type), SliceIterPtr(T), Iterator(...))
Item : *(T)next : (fn(self : *(Self)) -> Option(*(T)))Returns: Option(*(T))
FutureState — the state of an async Future.
Variants
| Variant | Fields | Description |
|---|---|---|
Pending | The future has been created but not yet started. | |
Running | The future is actively running. | |
Completed | The future completed successfully. | |
Aborted | The future was aborted (e.g., via |
Trait Implementations
impl(FutureState, Acyclic())
impl(FutureState, Runtime())
impl(FutureState, Send())
impl(FutureState, Eq(FutureState))
JoinHandle — a handle to a spawned async task.
Wraps a raw pointer to the spawned future's state machine.
Generic over T, the return type of the spawned task.
Type Parameters
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
impl(forall(T : Type), JoinHandle(T), ...)
await : __yo_join_handle_awaitAwait a Future, suspending until its result is ready.
Returns: unknown
Traits / Modules
Comptime trait — indicates a type that can be used at compile-time.
Examples: i32, bool, Type, comptime_int, comptime_float, comptime_string.
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_string, Type (compile-time-only types).
Implementors
Acyclic trait - indicates a type that cannot form reference cycles. Types that implement Acyclic don't need cycle collection tracking. Primitive types, value types without object fields, and objects that don't reference back to themselves (directly or indirectly) are Acyclic.
Implementors
The Rc trait means the type is reference counted object type.
Dispose trait - defines a dispose method for cleaning up resources.
Methods
dispose : fn(self : Self) -> unitParameters
| Name | Type | Notes |
|---|---|---|
self | Self |
Returns: unit
Implementors
Index trait — enables container(idx) subscript syntax at runtime.
The Idx parameter is the index type (e.g., usize, Range(usize)).
Implementations must define an Output associated type and an index method.
Type Parameters
| Name | Type | Notes |
|---|---|---|
Idx | Type | comptime |
Implementors
ComptimeIndex — compile-time indexing trait for constant expressions.
Type Parameters
| Name | Type | Notes |
|---|---|---|
Idx | Type | comptime |
Implementors
RangeInclusiveOp trait — enables start..=end operator syntax.
Methods
..= : fn(start : Self, end : Self) -> RangeInclusive(Self)Implementors
Methods
.. : fn(comptime(start) : Self, comptime(end) : Self) -> (comptime(fn_return_yocd6da6f3_id_1328) : Range(Self))Implementors
Methods
..= : fn(comptime(start) : Self, comptime(end) : Self) -> (comptime(fn_return_yocd6da6f3_id_1361) : RangeInclusive(Self))Implementors
Add trait — enables lhs + rhs operator. Parameterized by Rhs type.
Type Parameters
| Name | Type | Notes |
|---|---|---|
Rhs | Type | comptime |
Implementors
Exponentiation trait — enables lhs ** rhs operator.
Type Parameters
| Name | Type | Notes |
|---|---|---|
Rhs | Type | comptime |
Type Parameters
| Name | Type | Notes |
|---|---|---|
Rhs | Type | comptime |
Negate trait — enables unary -value operator.
Associated Types
| Name | Constraint | Description |
|---|---|---|
Output | Type | The output type of the addition. |
Methods
neg : fn(self : Self) -> OutputParameters
| Name | Type | Notes |
|---|---|---|
self | Self |
Returns: Output
Implementors
Associated Types
| Name | Constraint | Description |
|---|---|---|
Output | Type | The output type of the addition. |
Methods
neg : fn(comptime(self) : Self) -> (comptime(fn_return_yocd6da6f3_id_2151) : Output(Comptime))Implementors
Methods
! : fn(comptime(self) : Self) -> (comptime(fn_return_yocd6da6f3_id_2173) : bool)Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | comptime |
Returns: bool
Implementors
BitNot trait — enables ~value bitwise complement.
Associated Types
| Name | Constraint | Description |
|---|---|---|
Output | Type | The output type of the addition. |
Methods
~ : fn(self : Self) -> OutputParameters
| Name | Type | Notes |
|---|---|---|
self | Self |
Returns: Output
Implementors
Associated Types
| Name | Constraint | Description |
|---|---|---|
Output | Type | The output type of the addition. |
Methods
~ : fn(comptime(self) : Self) -> (comptime(fn_return_yocd6da6f3_id_2227) : Output(Comptime))Implementors
BitAnd trait — enables lhs & rhs bitwise AND.
Type Parameters
| Name | Type | Notes |
|---|---|---|
Rhs | Type | comptime |
Implementors
BitXor trait — enables lhs ^ rhs bitwise XOR.
Type Parameters
| Name | Type | Notes |
|---|---|---|
Rhs | Type | comptime |
Implementors
Eq trait — enables == and != comparison operators.
The != method has a default implementation that negates ==.
Type Parameters
| Name | Type | Notes |
|---|---|---|
Rhs | Type | comptime |
Implementors
Ord trait — enables <, <=, >, >= comparison operators.
Requires the type to also implement Eq.
Type Parameters
| Name | Type | Notes |
|---|---|---|
Rhs | Type | comptime |
Implementors
Hash trait - Similar to Rust's std:#️⃣:Hash
This trait defines the ability to hash a value into a u64. Types that implement Hash can be used as keys in HashMap and HashSet.
The hash function should satisfy:
- Deterministic: The same value always produces the same hash
- Consistent with Eq: If a == b, then hash(a) == hash(b)
Note: Unlike Rust which uses a Hasher trait for incremental hashing, we use a simpler approach where each type directly produces a u64 hash.
Methods
hash : fn(self : *(Self)) -> u64Compute the hash of a value Returns a u64 hash value
Parameters
| Name | Type | Notes |
|---|---|---|
self | *(Self) |
Returns: u64
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
Isolation trait — runtime check whether a value can be safely transferred.
Methods
can_isolate : fn(self : Self) -> boolParameters
| Name | Type | Notes |
|---|---|---|
self | Self |
Returns: bool
Implementors
Iterator trait — lazy, pull-based sequence traversal.
Associated Types
| Name | Constraint | Description |
|---|---|---|
Item | Type | The type of elements yielded by this iterator. |
Methods
next : fn(self : *(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
TryFrom trait — fallible conversion from one type to another.
Type Parameters
| Name | Type | Notes |
|---|---|---|
From | Type | comptime |
TryInto trait — fallible conversion of Self into another type.
Type Parameters
| Name | Type | Notes |
|---|---|---|
To | Type | comptime |
IO module — the async runtime effect.
Provides io.async, io.await, io.spawn, and io.state operations.
Automatically injected into main when declared with using(io : IO).
Methods
async : fn(forall(comptime(T) : Type, comptime(E) : Type(1)), action : Impl(Fn(using(...(E))) -> T)) -> Impl(Future(T, ...(E)))Create a new Future from an async closure.
Parameters
| Name | Type | Notes |
|---|---|---|
action | Impl(Fn(using(...(E))) -> T) |
Returns: Impl(Future(T, ...(E)))
await : fn(forall(comptime(T) : Type, comptime(E) : Type(1)), fut : Impl(Future(T, ...(E))), using(...(E))) -> TAwait a Future, suspending until its result is ready.
Parameters
| Name | Type | Notes |
|---|---|---|
fut | Impl(Future(T, ...(E))) |
Returns: T
state : fn(forall(comptime(T) : Type, comptime(E) : Type(1)), fut : Impl(Future(T, ...(E)))) -> FutureStateInspect the current state of a Future without blocking.
Parameters
| Name | Type | Notes |
|---|---|---|
fut | Impl(Future(T, ...(E))) |
Returns: FutureState
spawn : fn(forall(comptime(T) : Type, comptime(E) : Type(1)), fut : Impl(Future(T, ...(E))), using(...(E))) -> JoinHandle(T)Spawn a Future as an independent task, returning a JoinHandle.
Parameters
| Name | Type | Notes |
|---|---|---|
fut | Impl(Future(T, ...(E))) |
Returns: JoinHandle(T)
Functions
Parameters
| Name | Type | Notes |
|---|---|---|
flag | bool | |
msg | str | default: [object Object] |
Returns: unit
if macro — expands to cond(condition => then, true => else).
Example
if(x > 0, println("positive"), println("non-positive"));
Parameters
| Name | Type | Notes |
|---|---|---|
condition | Expr | comptime |
then | Expr | comptime |
else | Expr | comptime, default: [object Object] |
Returns: Expr
for macro — iterate over a collection using the Iterator trait.
Example
for arr.iter(), (value) => {
printf("value %d\n", value.*);
};
Parameters
| Name | Type | Notes |
|---|---|---|
iter | Expr | comptime |
handle | Expr | comptime |
Returns: Expr
Constants
The unsafe module — provides low-level escape hatches.
Value: unsafe(drop: <fn drop>, cast: __yo_as)
Value: !(Call: (<fn not>, <fn comptime_not>))
Value: !(Call: (<fn not>, <fn comptime_not>))
Value: ~(Call: (<fn bit_not>, <fn comptime_bit_not>))
Value: -(Call: (<fn neg>, <fn comptime_neg>))
Var — compile-time variable introspection utilities.
Provides macros for querying metadata about a variable at compile-time, such as ownership status and alias information.
Value: Var(print_info: <fn print_info>, is_owning_the_rc_value: <fn is_owning_the_rc_value>, has_other_aliases: <fn has_other_aliases>)