opt

package
v1.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func And

func And[T any, U any](o gust.Option[T], optb gust.Option[U]) gust.Option[U]

And returns [`None`] if the option is [`None`], otherwise returns `optb`.

func AndThen

func AndThen[T any, U any](o gust.Option[T], f func(T) gust.Option[U]) gust.Option[U]

AndThen returns [`None`] if the option is [`None`], otherwise calls `f` with the wrapped value.

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 FuzzyAssert added in v1.6.0

func FuzzyAssert[T any, U any](o gust.Option[T]) gust.Option[U]

FuzzyAssert asserts gust.Option[T] as gust.Option[U]. NOTE:

If the assertion fails, return none.

func Map

func Map[T any, U any](o gust.Option[T], f func(T) U) gust.Option[U]

Map maps an `gust.Option[T]` to `gust.Option[U]` by applying a function to a contained value.

func MapOr

func MapOr[T any, U any](o gust.Option[T], defaultSome U, f func(T) U) U

MapOr returns the provided default value (if none), or applies a function to the contained value (if any).

func MapOrElse

func MapOrElse[T any, U any](o gust.Option[T], defaultFn func() U, f func(T) U) U

MapOrElse computes a default function value (if none), or applies a different function to the contained value (if any).

func SafeAssert added in v1.6.0

func SafeAssert[T any, U any](o gust.Option[T]) gust.Result[gust.Option[U]]

SafeAssert asserts gust.Option[T] as gust.Result[gust.Option[U]]. NOTE:

If the assertion fails, return error.

func Unzip added in v0.7.0

func Unzip[T any, U any](p gust.Option[gust.Pair[T, U]]) gust.Pair[gust.Option[T], gust.Option[U]]

Unzip unzips an option containing a `Pair` of two values.

func XFuzzyAssert added in v1.6.0

func XFuzzyAssert[U any](o gust.Option[any]) gust.Option[U]

XFuzzyAssert asserts gust.Option[any] as gust.Option[U]. NOTE:

If the assertion fails, return none.

func XSafeAssert added in v1.6.0

func XSafeAssert[U any](o gust.Option[any]) gust.Result[gust.Option[U]]

XSafeAssert asserts gust.Option[any] as gust.Result[gust.Option[U]]. NOTE:

If the assertion fails, return error.

func Zip added in v0.7.0

func Zip[A any, B any](a gust.Option[A], b gust.Option[B]) gust.Option[gust.Pair[A, B]]

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL