unit
type unit
Source: compiler/src/builtin_docs/types.hy The type with a single value, (), used where there is no meaningful value.
A function with no -> return type returns unit, and statements have
type unit. It is also written void (for example as an FFI return
type). Result<unit, E> is the usual result of an operation that can
fail but returns nothing.
Examples#
use tests::assert;
fn check(int n) -> Result<unit, string> {
if n < 0 {
raise "negative";
}
return ();
}
fn main() {
let ok = match check(1) {
Result::Ok(_) => true,
Result::Err(_) => false,
};
assert!(ok);
}