Keyboard shortcuts

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

std/optional

optional represents an optional value.

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