std::resultResult helper functions โ pure Hew alternatives to the Rust FFI runtime.
These functions provide idiomatic Hew wrappers for common Result<T, E>
operations. They use match on the built-in Result type and avoid
FFI calls entirely for the supported element types.
import std::result;
fn main() {
let x: Result<int, int> = Ok(42);
println(result.is_ok_int(x)); // true
println(result.unwrap_or_int(x, 0)); // 42
let y: Result<int, int> = Err(1);
println(result.is_err_int(y)); // true
println(result.unwrap_or_int(y, -1)); // -1
}
is_ok_intReturns true if the result contains an Ok value.
is_err_intReturns true if the result contains an Err value.
unwrap_intUnwrap the Ok value. Panics if the result is Err.
unwrap_err_intUnwrap the Err value. Panics if the result is Ok.
unwrap_or_intUnwrap the Ok value, or return fallback if Err.
map_intApply f to the contained Ok value, or return Err unchanged.
map_err_intApply f to the contained Err value, or return Ok unchanged.
contains_intReturns true if the result is Ok and contains needle.
is_ok_strReturns true if the result contains an Ok value.
is_err_strReturns true if the result contains an Err value.
unwrap_strUnwrap the Ok value. Panics if the result is Err.
unwrap_err_strUnwrap the Err value. Panics if the result is Ok.
unwrap_or_strUnwrap the Ok value, or return fallback if Err.
contains_strReturns true if the result is Ok and contains needle.
is_ok_f64Returns true if the result contains an Ok value.
is_err_f64Returns true if the result contains an Err value.
unwrap_f64Unwrap the Ok value. Panics if the result is Err.
unwrap_or_f64Unwrap the Ok value, or return fallback if Err.