Skip to content

std.builtins - ZZ

Function Signature Notes
print / println (...values: T) -> unit Variadic: prints every argument space-separated (println() prints only a newline). Unwrap one layer: .ok(v)/.some(v) print v, bare .none prints none. Bare .err aborts — match it. Bare fn value is a compile error.
input (prompt: str) -> str Line from stdin. Prompt arg optional.
typeof (v: T) -> str Name string: "int", "str", "bytes", …
str (v: T) -> str Keeps wrappers (.ok(1) stays ".ok(1)", unlike println).
int (v: T) -> Option<int> Parse/convert; .none on failure. Use ?? fallback.
float (v: T) -> Option<float> Same as int.
len (v: T) -> int Arrays, tuples, bytes, strings (chars), dicts, ranges.
range (stop) / (start, stop) / (start, stop, step) range(5) is 0..5.
map (arr, f) -> [U] Also std.vec.
filter (arr, pred) -> [T] Also std.vec.
enumerate (arr) Index+value pairs. Also vec.enumerate.
zip (a, b) Pair elements.
clone (v: T) -> T Pin an independent deep copy.
asserts assert, assert_eq, assert_ne, … Bare and std.test.*. See Test.
println("hello")
println("value:", 42, true) // value: 42 true
name := input("name: ")
println("hi {name}, len {len(name)}")
n := int("42") ?? 0
f := float("3.14") ?? 0.0
evens := [x for x in range(10) if x % 2 == 0]
doubled := map([1, 2, 3], |x| x * 2)

Available via method dispatch on variant values:

x := .some(42)
x.unwrap() // 42
x.unwrap_or(0) // 42
x.expect("missing") // 42
y: Option<int> = .none
y.unwrap_or(0) // 0
ok := .ok(42)
ok.unwrap_or(0) // 42
e: Result<int, str> = .err("boom")
e.unwrap_or(0) // 0

unwrap/expect panic on the wrong variant. Prefer match, ?, or unwrap_or.

47 entries. Signatures come from the compiler’s own FuncSig table, so they match the runtime exactly; descriptions come from the module guide.

Function Signature Description
assert assert(cond: bool) -> unit —
assert_approx_eq assert_approx_eq(left: float, right: float, epsilon: float) -> unit —
assert_contains assert_contains(hay: str, needle: str) -> unit —
assert_ends_with assert_ends_with(s: str, suffix: str) -> unit —
assert_eq assert_eq<T>(left: T, right: T) -> unit —
assert_gt assert_gt<T,U>(left: T, right: U) -> unit —
assert_is_err assert_is_err<T,E>(val: Result<T, E>) -> unit —
assert_is_none assert_is_none<T>(val: Option<T>) -> unit —
assert_is_ok assert_is_ok<T,E>(val: Result<T, E>) -> unit —
assert_is_some assert_is_some<T>(val: Option<T>) -> unit —
assert_len assert_len<T>(val: T, n: int) -> unit —
assert_lt assert_lt<T,U>(left: T, right: U) -> unit —
assert_ne assert_ne<T>(left: T, right: T) -> unit —
assert_snapshot assert_snapshot(actual: str, name: str) -> unit —
assert_starts_with assert_starts_with(s: str, prefix: str) -> unit —
black_box black_box<T>(val: T) -> T —
chr chr(cp: int) -> str —
clone clone<T>(v: T) -> T Pin an independent deep copy.
dbg dbg<T>(v: T) -> T —
enumerate enumerate<T>(arr: [T] | T..) -> [(int, T)] Index+value pairs. Also vec.enumerate.
fail fail(msg: str) -> unit —
filter filter<T>(arr: [T] | T.., f: func(T) -> bool) -> [T] Also std.vec.
float float<T>(v: T) -> float Same as int.
free_port free_port() -> Result<int, str> —
input input<T>(prompt: str) -> str Line from stdin. Prompt arg optional.
int int<T>(v: T) -> Option<int> Parse/convert; .none on failure. Use ?? fallback.
len len<T>(v: T) -> int Arrays, tuples, bytes, strings (chars), dicts, ranges.
map map<T,U>(arr: [T] | T.., f: func(T) -> U) -> [U] Also std.vec.
ord ord(ch: str) -> int —
panic panic(msg: str) -> unit —
print print<T>(v: T) -> unit Variadic: prints every argument space-separated (println() prints only a newline). Unwrap one layer: .ok(v)/.some(v) print v, bare .none prints none. Bare .err aborts — match it. Bare fn value is a compile error.
println println<T>(v: T) -> unit Variadic: prints every argument space-separated (println() prints only a newline). Unwrap one layer: .ok(v)/.some(v) print v, bare .none prints none. Bare .err aborts — match it. Bare fn value is a compile error.
range range(start: int, stop: int, step: int) -> int.. range(5) is 0..5.
str str<T>(v: T) -> str Keeps wrappers (.ok(1) stays “.ok(1)”, unlike println).
temp_dir temp_dir(prefix: str) -> Result<str, str> —
typeof typeof<T>(v: T) -> str Name string: “int”, “str”, “bytes”, …
upgrade upgrade<T>(v: T) -> T —
weak weak<T>(v: T) -> T —
zip zip<T,U>(a: [T] | T.., b: [U] | U..) -> [(T, U)] Pair elements.
option.expect expect<T>(opt: Option<T>, msg: str) -> T —
option.unwrap unwrap<T>(opt: Option<T>) -> T —
option.unwrap_or unwrap_or<T>(opt: Option<T>, default: T) -> T —
result.expect expect<T,E>(res: Result<T, E>, msg: str) -> T —
result.unwrap unwrap<T,E>(res: Result<T, E>) -> T —
result.unwrap_or unwrap_or<T,E>(res: Result<T, E>, default: T) -> T —
span.end end(sp: span) -> int —
std.span.end end(sp: span) -> int —
  • std.vec — Array pipelines: push, pop, sort, join, fold and the numeric aggregates.
  • std.bytes — Contiguous byte buffers: builders, length, extension and UTF-8 conversion.

Full index: API reference · Standard library