std/optional
optional
import "std/optional";
fun maybe_value(ok: bool) -> optional<int64> {
if ok { return optional<int64>::of(42); }
return optional<int64>::empty();
}
Key APIs:
- of
- empty
- has_value
- is_empty
- value
- value_or
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
optional
import "std/optional";
fun maybe_value(ok: bool) -> optional<int64> {
if ok { return optional<int64>::of(42); }
return optional<int64>::empty();
}
Key APIs: