Documentation
¶
Overview ¶
Package opt provides a generic optional value.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Opt ¶
Opt is an optional value, an empty value is unset.
func Maybe ¶
func Maybe[T comparable](value T) Opt[T]
Maybe returns a new set value if not zero, otherwise an unset value.
func (Opt[T]) MustUnwrap ¶
func (o Opt[T]) MustUnwrap() T
MustUnwrap returns the value or panics if not set.
func (Opt[T]) Or ¶
func (o Opt[T]) Or(default_ T) T
Or returns the value if set, otherwise returns the default value.
Click to show internal directories.
Click to hide internal directories.