std-core
Option and Result, the canonical optional/error types.
Types
Option
type Option<T> = Some(T) | NoneSome(value) — an optional value is present.
Result
type Result<T, E> = Ok(T) | Err(E)Ok(value) or Err(error) — explicit success/failure without exceptions.
Functions
some
function some<T>(value: T): Option<T>Wrap value in Some.
isSome
function isSome<T>(o: Option<T>): booleanReturn true when the option is Some.
unwrapOr
function unwrapOr<T>(o: Option<T>, fallback: T): TReturn value from Some, or fallback for None.
ok
function ok<T, E>(value: T): Result<T, E>Construct Ok(value).
err
function err<T, E>(error: E): Result<T, E>Construct Err(error).
isOk
function isOk<T, E>(r: Result<T, E>): booleanresultOr
function resultOr<T, E>(r: Result<T, E>, fallback: T): T