Skip to content

Functions

Checks at runtime whether an Unknown value is type T. Equivalent to Go’s v, ok := x.(T).

fn assert_type<T>(value: Unknown) -> Option<T>
let value: Unknown = get_unknown_value()
let n = assert_type<int>(value)?Some(n) if the expected type, else None

Creates a complex number from real and imaginary parts.

fn complex(r: float64, i: float64) -> complex128
let z = complex(3.0, 4.0)(3+4i)

Returns the imaginary part of a complex number.

fn imaginary(c: complex128) -> float64
let z = complex(3.0, 4.0)
let imaginary_part = imaginary(z)4

Returns the largest of its arguments, which must share one Ordered type.

fn max<T: Ordered>(x: T, rest: VarArgs<T>) -> T
let largest = max(3, 1, 2)3
let last_word = max("pear", "apple")"pear", compared alphabetically

Returns the smallest of its arguments, which must share one Ordered type.

fn min<T: Ordered>(x: T, rest: VarArgs<T>) -> T
let smallest = min(3, 1, 2)1
let first_word = min("pear", "apple")"apple", compared alphabetically

Terminates the program with the given value.

fn panic(msg: Unknown) -> Never
panic("something went wrong")
panic(err)

Returns the real part of a complex number.

fn real(c: complex128) -> float64
let z = complex(3.0, 4.0)
let real_part = real(z)3