std/core/util
std/core/util — small utilities (Optional / Pair / OptionalCell).Optional<T>, Pair<A, B> and OptionalCell<T> are implementable in pure Axle
without any FFI: they're tiny generic classes whose methods are
straight assignments / branches over their fields. The richerOptional::map(fn) / filter(fn) variants require lambda
support, so this module exposes the no-lambda subset.
C class Pair<A, B>
An immutable two-value tuple — first / second are set once at
construction and read back as plain fields.
Constructors
| Type | Method and description |
|---|---|
| constructor(first : A, second : B) Pair holding first and second. |
Method detail
#constructor
Pair holding first and second.
first value stored in the first fieldsecond value stored in the second fieldC class Optional<T>
Minimal surface: the heavy map / filter / ifPresent
methods require lambdas (deferred). orElse(fallback) is the
only safe accessor — a typed get() throws NoSuchElementException
depends on the throwing-i32-return gap (api/stdlib.md #9).
Constructors
| Type | Method and description |
|---|---|
| constructor(present : bool, v : T) Low-level constructor: present flags whether v is a real value.When present is false, v is an ignored placeholder. |
Method detail
#constructor
Low-level constructor: present flags whether v is a real value.
When present is false, v is an ignored placeholder.
present true if v is a real value, false if absentv the held value; ignored placeholder when present is falseMethods
| Type | Method and description |
|---|---|
| isPresent(self) : bool true when this holds a value. |
| isEmpty(self) : bool true when this is empty (absent value). |
| orElse(self, fallback : T) : T The contained value if present, otherwise fallback. |
Method detail
#isPresent
true when this holds a value.
#isEmpty
true when this is empty (absent value).
#orElse
The contained value if present, otherwise fallback.
fallback value returned when this Optional is emptyfallbackC class OptionalCell<T>
A cell that may be empty, kept in an Optional<T> of its own: a generic
class naming another generic class on its type parameter.OptionalCell<i32> holds an Optional<i32>, built by its constructor and
read through its methods.
Constructors
| Type | Method and description |
|---|---|
| constructor(present : bool, v : T) Cell holding v when present, empty otherwise. |
Method detail
#constructor
Cell holding v when present, empty otherwise.
present true if v is a real value, false for an empty cellv the held value; ignored placeholder when present is falseMethods
| Type | Method and description |
|---|---|
| isPresent(self) : bool true when the cell holds a value. |
| orElse(self, fallback : T) : T The held value if present, otherwise fallback. |
Method detail
#isPresent
true when the cell holds a value.
#orElse
The held value if present, otherwise fallback.
fallback value returned when the cell is emptyfallback