types/opt

Types

Err[E] = Result[void, E]
Opt[T] = Result[T, void]
Result[T; E] = object
  when E is void and T is void:
    isOk*: bool
  elif E is void and T isnot void:
    case isOk*: bool
    of true:
      value*: T
    else:
      nil
  elif E isnot void and T is void:
    case isOk*: bool
    of true:
      nil
    else:
      error*: E
  else:
    case isOk*: bool
    of true:
      value*: T
    else:
      error*: E

Procs

proc get[T, E](res: Result[T, E]; v: T): T

Templates

template `:=`(a, res: untyped): bool
template `?`[T, E](res: Result[T, E]): auto
template err(): auto
template err[E](e: E): auto
template err[T, E](t: type Result[T, E]; e: E): Result[T, E]
template err[T](t: type Result[T, ref object]): auto
template err[T](t: type Result[T, void]): Result[T, void]
template get[T, E](res: Result[T, E]): T
template isErr(res: Result): bool
template ok(): auto
template ok[E](t: type Err[E]): Err[E]
template ok[T, E](t: type Result[T, E]; x: T): Result[T, E]
template ok[T](x: T): auto
template opt(t: typedesc): auto
template opt[T](v: T): auto