Documentation ¶
Index ¶
- func Chain[A, B any](fn func(a A) Option[B]) func(Option[A]) Option[B]
- func Exists[T any](predicate func(value T) bool) func(Option[T]) bool
- func FromPredicate[T any](predicate func(value T) bool) func(T) Option[T]
- func GetOrElse[T any](onNone fp.Lazy[T]) func(Option[T]) T
- func IsNone[T any](o Option[T]) bool
- func IsSome[T any](o Option[T]) bool
- func Map[T, R any](fn func(value T) R) func(o Option[T]) Option[R]
- func Match[T, R any](onNone fp.Lazy[R], onSome func(value T) R) func(Option[T]) R
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Chain ¶
Execute a function that returns an Option on the Option value if it exists. Otherwise return the empty Option itself
func Exists ¶ added in v0.11.0
Returns `false` if `None` or returns the boolean result of the application of the given predicate to the `Some` value
func FromPredicate ¶ added in v0.11.0
Constructor of Option from a predicate. Returns a None if the predicate function over the value return false. Returns a Some if the predicate function over the value return true.
func GetOrElse ¶
Extracts the value out of the Option, if it exists. Otherwise returns the function with a default value
Types ¶
type Option ¶
type Option[T any] struct { Value T // contains filtered or unexported fields }
Base struct
func Flatten ¶ added in v0.11.0
Removes one level of nesting. Returns its bound argument into the outer level.
func FromError ¶ added in v0.11.0
Constructor of Option from any couple of mutually exclusive `value` and `error`. Returns a None in case we have an error, Some if we have a value and error is nil.
func FromErrorFn ¶ added in v0.11.0
Constructor of Option from any lazy function that returns a couple of mutually exclusive `value` and `error`. Returns a None in case we have a return error, Some if we have return value and error is nil.