opt

package
v1.2.2-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 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

func Assert added in v0.7.0

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

Assert asserts gust.Option[T] as gust.Option[U].

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

func EnumOkOr[T any, E any](o gust.Option[T], err E) gust.EnumResult[T, E]

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

func EnumOkOrElse[T any, E any](o gust.Option[T], errFn func() E) gust.EnumResult[T, E]

EnumOkOrElse transforms the `Option[T]` into a [`EnumResult[T,E]`], mapping [`Some(v)`] to [`EnumOk(v)`] and [`None`] to [`EnumErr(errFn())`].

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 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 XAssert added in v0.7.0

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

XAssert asserts gust.Option[any] as gust.Option[U].

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