Packages

builtin
cbindgen
core
core.alloc
core.alloc.arena
core.alloc.atomic
core.alloc.debug
core.alloc.fixed
core.alloc.gc
core.alloc.heap
core.alloc.log
core.alloc.memwatch
core.alloc.pool
core.alloc.ring
core.arg_parse
core.array
core.avl_tree
core.bucket_array
core.conv
core.crypto
core.crypto.keys
core.doc
core.encoding
core.encoding.base64
core.encoding.csv
core.encoding.hex
core.encoding.json
core.encoding.kdl
core.encoding.osad
core.encoding.utf8
core.encoding.xml
core.hash
core.hash.md5
core.hash.sha1
core.hash.sha256
core.heap
core.intrinsics
core.intrinsics.atomics
core.intrinsics.onyx
core.intrinsics.types
core.intrinsics.wasm
core.io
core.io.binary
core.iter
core.js
core.list
core.map
core.math
core.memory
core.misc
core.net
core.os
core.random
core.set
core.slice
core.string
core.sync
core.test
core.thread
core.time
main
runtime
runtime.info
runtime.platform
runtime.vars
simd

package core

Pair
Pair :: struct (First_Type: type_expr, Second_Type: type_expr) {
    first: First_Type
    second: Second_Type
}

A Pair represents a pair of values of heterogenous types. This structure does not do much on its own; however, it is useful because provides overloads for formatting, hashing and equality. This means you can use a Pair(T, R) as a key for a Map or Set out of the box, provided T and R are hashable and equatable.

Methods
Pair._format
Pair._format :: (output: &conv.Format_Output, format: &conv.Format, p: &Pair($First_Type, $Second_Type)) -> void
Pair.make
Pair.make :: macro (x: $X, y: $Y) -> #auto
cptr
cptr :: struct (T: type_expr) {
    data: u64
}
Methods
cptr.as_unsafe
cptr.as_unsafe :: (this: cptr($T), $new_type: type_expr) -> cptr(new_type)
cptr.at
cptr.at :: (this: cptr($T), index: i32) -> T
cptr.extract_str
cptr.extract_str :: (this: cptr(u8), dest: [] u8) -> u32
cptr.format
cptr.format :: (output: &conv.Format_Output, format: &conv.Format, p: &cptr($T)) -> void
cptr.make
cptr.make :: macro (ptr: &$T) -> cptr(T)
cptr.read
cptr.read :: (this: cptr(void)) -> void
cptr.read :: (this: cptr($T)) -> T
cptr.read :: (this: cptr($T), buffer: [] u8) -> void
cptr.read_i16
cptr.read_i16 :: (this: cptr(i16)) -> i16
cptr.read_i32
cptr.read_i32 :: (this: cptr(i32)) -> i32
cptr.read_i64
cptr.read_i64 :: (this: cptr(i64)) -> i64
cptr.read_i8
cptr.read_i8 :: (this: cptr(i8)) -> i8
cptr.read_u16
cptr.read_u16 :: (this: cptr(u16)) -> u16
cptr.read_u32
cptr.read_u32 :: (this: cptr(u32)) -> u32
cptr.read_u64
cptr.read_u64 :: (this: cptr(u64)) -> u64
cptr.read_u8
cptr.read_u8 :: (this: cptr(u8)) -> u8
cptr.to_rawptr
cptr.to_rawptr :: (this: cptr($T)) -> &T
Result
Result :: union (Ok_Type: type_expr, Err_Type: type_expr) {
    Err: Err_Type
    Ok: Ok_Type
}

Result(T, E) is a structure that represents either an Ok value of type T, or an Err value of type E. status contains either .Ok, or .Err depending on which is currently held.

Methods
Result.and_then
Result.and_then :: (r: Result, f: (r.Ok_Type) -> Result($R, r.Err_Type)) -> Result(R, r.Err_Type)

Monadic chaining operation.

Result.catch
Result.catch :: macro (r: Result($T, $E), on_err: Code) -> T

If result contains Err, the given code is run. This code is expected to either:

  • Return a good value with return
  • Return an error value with return return

This procedure is subject to change.

Result.err
Result.err :: (r: Result) -> Optional(r.Err_Type)

Returns an Optional of the Err type.

Result.expect
Result.expect :: (r: Result, msg: [] u8) -> r.Ok_Type

Tries to extract the Ok value out of the Result. If the result contains an Err, a custom assertion message is thrown.

Result.forward_err
Result.forward_err :: macro (r: Result($T, $E)) -> T

If result contains Err, the error is returned from the enclosing procedure. Otherwise, the Ok value is returned.

f :: () -> Result(i32, str) {
    return .{ Err = "Oh no..." };
}

g :: () -> Result(str, str) {
    // This returns from g with the error returned from f.
    v := f()->forward_err();
    println(v);
    
    return .{ Ok = "Success!" };
}
Result.is_err
Result.is_err :: (r: Result) -> bool

Returns true if the result contains an Err value.

Result.is_ok
Result.is_ok :: (r: Result) -> bool

Returns true if the result contains an Ok value.

Result.ok
Result.ok :: (r: Result) -> Optional(r.Ok_Type)

Returns an Optional of the Ok type.

Result.or_else
Result.or_else :: (r: Result, generate: () -> unknown) -> #auto

If the Result contains Err, generate is called to make a value

Result.or_return
Result.or_return :: macro (r: Result($T, $E), v: $V) -> T

If result contains Err, the given value is returned from the enclosing procedure. Otherwise, the Ok value is returned.

Result.transform
Result.transform :: (r: Result($T, $E), f: (T) -> $R) -> Result(R, E)

Returns a new result defined by:

Ok(n)  => Ok(f(n))
Err(e) => Err(e)
Result.transform_err
Result.transform_err :: macro (r: Result($T, $E), f: (E) -> $N) -> Result(T, N)

If result contains Err, the error is mapped to a new error type.

Result.unwrap
Result.unwrap :: (r: Result) -> r.Ok_Type

Forcefully extracts the Ok value out of the Result. If the result contains an Err, an assertion is thrown.

Result.unwrap_or_default
Result.unwrap_or_default :: (r: Result) -> r.Ok_Type

Tries to extract the Ok value out of the Result. If the result contains an Err, the empty .{} value is returned.

__byte_dump
__byte_dump :: (ptr: rawptr, byte_count: u32, bytes_per_line: i32) -> void
__flush_stdio
__flush_stdio :: () -> void
__stdio_init
__stdio_init :: () -> void
aprintf
aprintf :: (format: [] u8, va: ..any) -> [] u8
eprintf
eprintf :: (format: [] u8, va: ..any) -> void
print
print :: (x: [] u8) -> void
print :: (x: $__type_x) -> #auto
print :: (x: $__type_x, y: $__type_y) -> #auto
printf
printf :: (format: [] u8, va: ..any) -> void
println
println :: (x: $__type_x) -> #auto
tprintf
tprintf :: (format: [] u8, va: ..any) -> [] u8