Skip to content

core

Global builtins available in every Ion program without `use`.

Builtins

assert

assert(cond) / assert(cond, msg)

Error if condition is false

assert_eq

assert_eq(a, b) / assert_eq(a, b, msg)

Error if values are not equal

bytes

bytes() / bytes(list) / bytes(string) / bytes(n)

Create bytes

bytes_from_hex

bytes_from_hex(string)

Bytes from hex string

cell

cell(value)

Create a mutable reference cell for shared closure state

channel

channel(buffer_size)

Create a buffered channel (tx, rx)

enumerate

enumerate(list)

List of (index, value) tuples

float

float(x)

Convert to float

int

int(x)

Convert to int

len

len(x)

Length of list, string, dict, or bytes

range

range(n) / range(start, end)

Create a range [0..n) or [start..end)

set

set() / set(list)

Create a set from a list (deduplicates elements)

sleep

sleep(ms)

Sleep for given milliseconds (requires concurrency feature)

str

str(x)

Convert to string

timeout

timeout(ms, fn)

Run function with time limit, returns Option (Some or None on timeout)

type_of

type_of(x)

Returns type name as string

Documentation reflects Ion v0.2.0-66-g3faa376.