Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrEmptyOption = errors.New("expected Option value was empty")
ErrEmptyOption is returned by Option.Unwrap when attempting to retrieve a value from an empty Option.
Functions ¶
This section is empty.
Types ¶
type Conversion ¶
Conversion is a function that converts a T into a U.
type Option ¶
type Option[T any] struct { // contains filtered or unexported fields }
Option represents an optional type.
func Map ¶
Map transforms an Option[T] into an Option[U] by applying the given conversion to T. None[T] is returned as None[U].
Errors ¶
- Any error returned by the conversion.
func None ¶
None returns an empty Option[T] whose zero-value is considered valid by [Option.NonZero] and [NonZero].
func (*Option[T]) UnmarshalJSON ¶
func (Option[T]) Unwrap ¶
Unwrap returns the value of the Option, or ErrEmptyOption error if the Option is empty.
func (Option[T]) UnwrapOrZero ¶
func (o Option[T]) UnwrapOrZero() T
UnwrapOrZero returns the value of the Option, which is the zero-value of T if the Option is None.
Click to show internal directories.
Click to hide internal directories.