Documentation ¶
Index ¶
- type Opt
- func (a Opt[T]) IfNone(action func())
- func (a Opt[T]) IfSome(action func(value T))
- func (a Opt[T]) IsNone() bool
- func (a Opt[T]) IsSome() bool
- func (a Opt[T]) Next() Opt[T]
- func (a Opt[T]) Or(value T) T
- func (a Opt[T]) OrDefault() (v T)
- func (a Opt[T]) OrPanic() T
- func (a Opt[T]) Val() (value T, ok bool)
- type Pair
- type Ref
- type Result
- func (a Result[T]) IfErr(action func(err error))
- func (a Result[T]) IfOk(action func(value T))
- func (a Result[T]) IsErr() bool
- func (a Result[T]) IsOk() bool
- func (a Result[T]) Or(value T) T
- func (a Result[T]) OrDefault() (v T)
- func (a Result[T]) OrPanic() T
- func (a Result[T]) Val() (value T, err error)
- type Void
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Opt ¶
type Opt[T any] struct { // contains filtered or unexported fields }
Type-safe nullable types. Provides a safe way to manipulate values that may be null. It is nestable.
func (Opt[T]) IfSome ¶
func (a Opt[T]) IfSome(action func(value T))
Execute the action when ok is true.
func (Opt[T]) Or ¶
func (a Opt[T]) Or(value T) T
Get the value in an safe way, and get else value when ok is false.
func (Opt[T]) OrDefault ¶
func (a Opt[T]) OrDefault() (v T)
Get the value in an safe way, and get else value when ok is false.
type Pair ¶
Pair is a combination type containing two elements.
type Result ¶
type Result[T any] struct { // contains filtered or unexported fields }
Type-safe errorable types. Provides a safe way to manipulate values that may be error. It is nestable.
func (Result[T]) IfOk ¶
func (a Result[T]) IfOk(action func(value T))
Execute the action when error is nil.
func (Result[T]) Or ¶
func (a Result[T]) Or(value T) T
Get the value in an safe way, and get else value when error is not nil.
Click to show internal directories.
Click to hide internal directories.