std::optionOption helper functions โ pure Hew alternatives to the Rust FFI runtime.
These functions provide idiomatic Hew wrappers for common Option<T>
operations. They use match on the built-in Option type and avoid
FFI calls entirely for the supported element types.
import std::option;
fn main() {
let x = Some(42);
println(option.is_some_int(x)); // true
println(option.unwrap_or_int(x, 0)); // 42
let y: Option<int> = None;
println(option.is_none_int(y)); // true
println(option.unwrap_or_int(y, -1)); // -1
}
is_some_intReturns true if the option contains a value.
is_none_intReturns true if the option is None.
unwrap_intUnwrap the int value. Panics if the option is None.
unwrap_or_intUnwrap the int value, or return fallback if None.
map_intApply f to the contained int value, or return None if empty.
contains_intReturns true if the option contains needle.
is_some_strReturns true if the option contains a value.
is_none_strReturns true if the option is None.
unwrap_strUnwrap the String value. Panics if the option is None.
unwrap_or_strUnwrap the String value, or return fallback if None.
contains_strReturns true if the option contains needle.
is_some_f64Returns true if the option contains a value.
is_none_f64Returns true if the option is None.
unwrap_f64Unwrap the f64 value. Panics if the option is None.
unwrap_or_f64Unwrap the f64 value, or return fallback if None.