Documentation ¶
Index ¶
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. It is either Some(value) or None. The Option type is generic and can hold any type of value. The zero value of Option is None.
func (Option[T]) Expect ¶
Expect panics with the given message if the Option is None. Otherwise, it returns the value.
func (Option[T]) Unwrap ¶
func (o Option[T]) Unwrap() T
Unwrap returns the value of the Option if it is Some. It panics if the Option is None.
func (Option[T]) UnwrapOr ¶
func (o Option[T]) UnwrapOr(def T) T
UnwrapOr returns the value of the Option if it is Some. Otherwise, it returns the given default value.
func (Option[T]) UnwrapOrDefault ¶
func (o Option[T]) UnwrapOrDefault() T
UnwrapOrDefault returns the value of the Option if it is Some. Otherwise, it returns the zero value of the type.
func (Option[T]) UnwrapOrElse ¶
func (o Option[T]) UnwrapOrElse(fn func() T) T
UnwrapOrElse returns the value of the Option if it is Some. Otherwise, it returns the result of the given function.