Documentation
¶
Index ¶
- type Option
- func (o *Option[T]) MarshalJSON() ([]byte, error)
- func (o Option[T]) None() bool
- func (o Option[T]) Some() (T, bool)
- func (o *Option[T]) UnmarshalJSON(b []byte) error
- func (o Option[T]) Unwrap() T
- func (o Option[T]) UnwrapOr(val T) T
- func (o Option[T]) UnwrapOrDefault() T
- func (o Option[T]) UnwrapOrElse(f func() T) T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option[T any] struct { // contains filtered or unexported fields }
Option represent an optional value.
func (*Option[T]) MarshalJSON ¶
func (Option[T]) Some ¶
Some returns the value, if any, and a bool indicating if the value is non-nil.
func (*Option[T]) UnmarshalJSON ¶
func (Option[T]) Unwrap ¶
func (o Option[T]) Unwrap() T
Unwrap extracts the value. It panics if the inner value is nil
func (Option[T]) UnwrapOr ¶
func (o Option[T]) UnwrapOr(val T) T
UnwrapOr extracts the value. If the inner value is nil it returns the value specified by `val`.
func (Option[T]) UnwrapOrDefault ¶
func (o Option[T]) UnwrapOrDefault() T
UnwrapOrDefault extracts the value. It returns the type specific default value if the inner value is nil.
func (Option[T]) UnwrapOrElse ¶
func (o Option[T]) UnwrapOrElse(f func() T) T
UnwrapOrElse extracts the value. If the inner value is nil it executes the specified function and returns its value.
Click to show internal directories.
Click to hide internal directories.