optional

package
v0.7.10 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package optional provides a way to represent optional values in Go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option[T any] interface {
	And(v Option[T]) Option[T]
	AndThen(f func(T) Option[T]) Option[T]
	Except(v any) T
	Filter(f func(T) bool) Option[T]
	IsNone() bool
	IsSome() bool
	Map(f func(T) T) Option[T]
	MapOr(v T, f func(T) T) T
	MapOrElse(def func() T, next func(T) T) T
	Or(v Option[T]) Option[T]
	OrElse(next func() Option[T]) Option[T]
	Replace(v T) Option[T]
	Unwrap() T
	UnwrapOr(v T) T
	UnwrapOrElse(f func() T) T
	Value() T
}

Option is a value that represents the presence of a value or the absence of a value.

func None

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

None is a value that represents the absence of a value.

func Some

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

Some is a value that represents the presence of a value.

func Wrap

func Wrap[T any](v T, null bool) Option[T]

Wrap returns an option that represents the presence of a value or the absence of a value.

Jump to

Keyboard shortcuts

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