option

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: MIT Imports: 2 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cast

func Cast[TSource, TTarget any](source types.Option[TSource]) types.Result[types.Option[TTarget]]

Cast attempts to cast a source option type of TSource to a result option type of TTarget if the cast fails, Error is returned if the cast succeeds, Ok is returned wrapping the Option[TTarget]

func Map added in v0.5.2

func Map[T, U any](op types.Option[T], transform func(t T) U) types.Option[U]

Map returns none if op is none applies the function to the value if some and returns some of the result

func MapOr added in v0.5.2

func MapOr[T, U any](op types.Option[T], transform func(t T) U, def U) U

MapOr returns the default value if none. or applies the function to the value if some

func MapOrElse added in v0.5.2

func MapOrElse[T, U any](op types.Option[T], transform func(t T) U, def func() U) U

MapOrElse evaluates the default function if none or applies the function to the value if some

func New

func New[T any](t T, ok bool) types.Option[T]

func None

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

func Some

func Some[T any](value T) types.Option[T]

Types

This section is empty.

Jump to

Keyboard shortcuts

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