Skip to main content

Module traits

Module traits 

Source
Expand description

Core trait dispatch — maps language features to trait method calls.

The interpreter’s expression evaluator uses TraitDispatch to resolve operators, for..in, and string interpolation to the corresponding trait method names registered in the [BuiltinRegistry].

§Trait-to-Language-Feature Mapping

Language FeatureTraitMethod
<, >, <=, >=Comparablecompare() -> Ordering
==, !=Equatableequals() -> Bool
for x in collectionIterableiter() -> Iterator
"${expr}"Displayabledisplay() -> String
x + y (non-primitive)Addadd(other) -> Self
x - y (non-primitive)Subsub(other) -> Self
x * y (non-primitive)Mulmul(other) -> Self
x / y (non-primitive)Divdiv(other) -> Self
x % y (non-primitive)Remrem(other) -> Self
Into[T] / From[T]Into/Frominto() -> T / from()

Structs§

TraitDispatch
Maps language features (operators, for..in, string interpolation) to trait method names, checking whether a given type has the required trait implementation registered.

Enums§

ConversionDirection
Direction for From/Into conversion dispatch.

Type Aliases§

MethodName
The name of a trait method (e.g., "compare", "equals", "iter").