Documentation
¶
Index ¶
- type Option
- func (o *Option[T]) Expect(msg string) T
- func (o *Option[T]) IsNone() bool
- func (o *Option[T]) IsSome() bool
- func (o Option[T]) IsZero() bool
- func (o Option[T]) MarshalJSON() ([]byte, error)
- func (o *Option[T]) UnmarshalJSON(b []byte) error
- func (o *Option[T]) Unwrap() T
- func (o *Option[T]) UnwrapOr(def T) T
- func (o *Option[T]) UnwrapOrElse(fn 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 is a type that represents an optional value.
func (Option[T]) MarshalJSON ¶
MarshalJSON emits the inner value when Some, or null when None.
func (*Option[T]) UnmarshalJSON ¶
UnmarshalJSON sets None on "null", or decodes T and sets Some.
func (*Option[T]) Unwrap ¶
func (o *Option[T]) Unwrap() T
Unwrap panics if the option is a None value.
func (*Option[T]) UnwrapOr ¶
func (o *Option[T]) UnwrapOr(def T) T
UnwrapOr returns the value of the option if it is a Some value, otherwise it returns the given default value.
func (*Option[T]) UnwrapOrElse ¶
func (o *Option[T]) UnwrapOrElse(fn func() T) T
UnwrapOrElse returns the value of the option if it is a Some value, otherwise it returns the result of the given function.
Click to show internal directories.
Click to hide internal directories.