Documentation ¶
Index ¶
- func And[T any, U any](o gust.Option[T], optb gust.Option[U]) gust.Option[U]
- func AndThen[T any, U any](o gust.Option[T], f func(T) gust.Option[U]) gust.Option[U]
- func Assert[T any, U any](o gust.Option[T]) gust.Option[U]
- func Contains[T comparable](o gust.Option[T], x T) bool
- func EnumOkOr[T any, E any](o gust.Option[T], err E) gust.EnumResult[T, E]
- func EnumOkOrElse[T any, E any](o gust.Option[T], errFn func() E) gust.EnumResult[T, E]
- func Map[T any, U any](o gust.Option[T], f func(T) U) gust.Option[U]
- func MapOr[T any, U any](o gust.Option[T], defaultSome U, f func(T) U) U
- func MapOrElse[T any, U any](o gust.Option[T], defaultFn func() U, f func(T) U) U
- func Unzip[T any, U any](p gust.Option[gust.Pair[T, U]]) gust.Pair[gust.Option[T], gust.Option[U]]
- func XAssert[U any](o gust.Option[any]) gust.Option[U]
- func Zip[A any, B any](a gust.Option[A], b gust.Option[B]) gust.Option[gust.Pair[A, B]]
- func ZipWith[T any, U any, R any](some gust.Option[T], other gust.Option[U], f func(T, U) R) gust.Option[R]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains[T comparable](o gust.Option[T], x T) bool
Contains returns `true` if the option is a [`Some`] value containing the given value.
func EnumOkOr ¶ added in v0.7.0
EnumOkOr transforms the `Option[T]` into a [`EnumResult[T,E]`], mapping [`Some(v)`] to [`EnumOk(v)`] and [`None`] to [`EnumErr(err)`].
func EnumOkOrElse ¶ added in v0.7.0
EnumOkOrElse transforms the `Option[T]` into a [`EnumResult[T,E]`], mapping [`Some(v)`] to [`EnumOk(v)`] and [`None`] to [`EnumErr(errFn())`].
func Map ¶
Map maps an `gust.Option[T]` to `gust.Option[U]` by applying a function to a contained value.
func MapOr ¶
MapOr returns the provided default value (if none), or applies a function to the contained value (if any).
func MapOrElse ¶
MapOrElse computes a default function value (if none), or applies a different function to the contained value (if any).
func Zip ¶ added in v0.7.0
Zip zips `a` with b `Option`.
If `a` is `gust.Some(s)` and `b` is `gust.Some(o)`, this method returns `gust.Some(gust.Pair{A:s, B:o})`. Otherwise, `None` is returned.
func ZipWith ¶
func ZipWith[T any, U any, R any](some gust.Option[T], other gust.Option[U], f func(T, U) R) gust.Option[R]
ZipWith zips `value` and another `gust.Option` with function `f`.
If `value` is `Some(s)` and `other` is `Some(o)`, this method returns `Some(f(s, o))`. Otherwise, `None` is returned.
Types ¶
This section is empty.