Skip to content

Ok Reference

Ok is a class that represents a successful result value. It is one of the two possible states of a Result.

Creates a Result representing a successful value.

var result = Ok(100);
  • value (dyn!) - The success value to wrap

All methods are inherited from the Result class. See the Result reference for documentation.

var success = Ok(42);
println(success.is_ok()); // true
println(success.unwrap()); // 42
println(success.unwrap_or(0)); // 42
var doubled = success.map((x) -> x * 2);
println(doubled.unwrap()); // 84