option

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2025 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func If

func If[Out, T any](r Option[T], someFn func(T) Out, noneFn func() Out) Out

Types

type Option

type Option[T any] struct {
	// contains filtered or unexported fields
}

func Cast

func Cast[T any](value any) Option[T]

func FlatMap added in v0.3.0

func FlatMap[T, U any](r Option[T], fn func(T) Option[U]) Option[U]

func Map added in v0.3.0

func Map[T, U any](r Option[T], fn func(T) U) Option[U]

func None

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

None is explicitly identical to the zero value of Option[T]

func Some

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

func (Option[T]) Expect

func (o Option[T]) Expect(panicMsg string) T

func (Option[T]) IsNone

func (o Option[T]) IsNone() bool

func (Option[T]) IsSome

func (o Option[T]) IsSome() bool

func (Option[T]) Some

func (o Option[T]) Some(out *T) bool

func (Option[T]) Unwrap

func (o Option[T]) Unwrap() T

func (Option[T]) UnwrapOr

func (o Option[T]) UnwrapOr(defaultValue T) T

func (Option[T]) UnwrapOrElse

func (o Option[T]) UnwrapOrElse(fn func() T) T

Jump to

Keyboard shortcuts

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