option

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter[A any](o lang.Option[A], f func(A) bool) lang.Option[A]

func FlatMap

func FlatMap[A, B any](o lang.Option[A], f func(A) lang.Option[B]) lang.Option[B]

func Flatten

func Flatten[T any](o lang.Option[lang.Option[T]]) lang.Option[T]

func ForEach

func ForEach[A any](o lang.Option[A], f func(A))

func FromEither

func FromEither[L, R any](e lang.Either[L, R]) lang.Option[R]

FromEither converts an Either instance to an Option instance. If the Either instance is a Left, an empty Option is returned. Otherwise, an Option with the right value is returned.

func Map

func Map[A, B any](o lang.Option[A], f func(A) B) lang.Option[B]

func None

func None[T any]() lang.Option[T]

None returns an empty Option.

func Of

func Of[T any](v T) lang.Option[T]

func OrElse

func OrElse[A any](o lang.Option[A], f func() lang.Option[A]) lang.Option[A]

OrElse returns the given Option if it is defined. Otherwise, it returns the result of the given function.

func Sequence

func Sequence[A any](os []lang.Option[A]) lang.Option[[]A]

Sequence merges a list of Option instances into a single Option instance. If any of the Option instances is empty, an empty Option is returned. Otherwise, an Option with the list of values is returned.

func Some

func Some[T any](t T) lang.Option[T]

Some returns an Option with the given value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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