Functions
assert_type()
Section titled “assert_type()”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 Nonecomplex()
Section titled “complex()”Creates a complex number from real and imaginary parts.
fn complex(r: float64, i: float64) -> complex128let z = complex(3.0, 4.0)(3+4i)imaginary()
Section titled “imaginary()”Returns the imaginary part of a complex number.
fn imaginary(c: complex128) -> float64let z = complex(3.0, 4.0)let imaginary_part = imaginary(z)4Returns the largest of its arguments, which must share one
Ordered type.
fn max<T: Ordered>(x: T, rest: VarArgs<T>) -> Tlet largest = max(3, 1, 2)3let last_word = max("pear", "apple")"pear", compared alphabeticallyReturns the smallest of its arguments, which must share one
Ordered type.
fn min<T: Ordered>(x: T, rest: VarArgs<T>) -> Tlet smallest = min(3, 1, 2)1let first_word = min("pear", "apple")"apple", compared alphabeticallypanic()
Section titled “panic()”Terminates the program with the given value.
fn panic(msg: Unknown) -> Neverpanic("something went wrong")panic(err)real()
Section titled “real()”Returns the real part of a complex number.
fn real(c: complex128) -> float64let z = complex(3.0, 4.0)let real_part = real(z)3