Result<T, E>
Fallible operations return Result<T, E> — an enum with two variants, Ok(T) and Err(E). The compiler enforces must_use semantics: ignoring a Result value without inspecting it is a compile error, so fallible APIs cannot be silently dropped.
use system.io
use system.result
fn divide(a int, b int) Result<int, String>
if b == 0
return Result.Err("division by zero")
return Result.Ok(a / b)
fn main()
match divide(10, 2)
Result.Ok(v): println(f"got {v}")
Result.Err(e): println(f"err: {e}")
// unwrap_or returns the Ok value or a fallback.
let safe = divide(10, 0).unwrap_or(-1)
println(f"{safe}")
// Predicates for quick inspection.
let r = divide(8, 4)
println(f"{r.is_ok()} {r.is_err()}")
Inspect a result with match for full extraction, or with the helpers is_ok(), is_err(), and unwrap_or(default) for quick paths. There is no unwrap() that panics on Err — Miri's standard library does not panic, so the failure path is always explicit at the call site.