optionals

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: MIT Imports: 1 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Optional

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

func None

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

func Some

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

func (Optional[T]) Get

func (opt Optional[T]) Get() (T, bool)

If this Optional is Some, returns the value inhabiting this Optional and true. Otherwise, returns the Go's default value for T and false.

func (Optional[T]) GetOrDefault

func (opt Optional[T]) GetOrDefault(defaultValue T) T

Returns the value inhabiting this Optional, or the given default value if this Optional is None.

func (Optional[T]) IsNone

func (opt Optional[T]) IsNone() bool

func (Optional[T]) IsSome

func (opt Optional[T]) IsSome() bool

func (Optional[T]) MarshalJSON

func (opt Optional[T]) MarshalJSON() ([]byte, error)

func (*Optional[T]) UnmarshalJSON

func (opt *Optional[T]) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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