optional.l0

optional.l0

Module: std.optional

Source: compiler/shared/l0/stdlib/std/optional.l0 Language: Dea/L0

Imports / Includes

  • std.assert

Symbols

Function unwrap_or_s

1
func unwrap_or_s(opt: string?, default: string) -> string

Unwraps an optional string, returning the contained value if present, otherwise returning the provided default string.

Parameters:

  • opt: The optional string to unwrap.
  • default: The default string value.

Returns: The unwrapped value or the default.

Function unwrap_or_i

1
func unwrap_or_i(opt: int?, default: int) -> int

Unwraps an optional int, returning the contained value if present, otherwise returning the provided default int.

Parameters:

  • opt: The optional integer to unwrap.
  • default: The default integer value.

Returns: The unwrapped value or the default.

Function unwrap_or_b

1
func unwrap_or_b(opt: bool?, default: bool) -> bool

Unwraps an optional bool, returning the contained value if present, otherwise returning the provided default bool.

Parameters:

  • opt: The optional boolean to unwrap.
  • default: The default boolean value.

Returns: The unwrapped value or the default.

Function expect_s

1
func expect_s(opt: string?, msg: string) -> string

Expects an optional string to be non-null, returning the contained value.

If the optional is null, it aborts with the provided message.

Parameters:

  • opt: The optional string.
  • msg: The abort message if null.

Returns: The unwrapped string value.

Function expect_i

1
func expect_i(opt: int?, msg: string) -> int

Expects an optional int to be non-null, returning the contained value.

If the optional is null, it aborts with the provided message.

Parameters:

  • opt: The optional integer.
  • msg: The abort message if null.

Returns: The unwrapped integer value.

Function expect_b

1
func expect_b(opt: bool?, msg: string) -> bool

Expects an optional bool to be non-null, returning the contained value.

If the optional is null, it aborts with the provided message.

Parameters:

  • opt: The optional boolean.
  • msg: The abort message if null.

Returns: The unwrapped boolean value.