optional

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Elem

type Elem[E any] struct {
	// contains filtered or unexported fields
}

Elem represents an optional value.

func Empty

func Empty[E any]() Elem[E]

Empty returns an empty optional value.

func Of

func Of[E any](v E) Elem[E]

Of returns an optional value with the given value.

func (Elem[E]) IsEmpty

func (o Elem[E]) IsEmpty() bool

IsEmpty returns true if the value is not present.

func (Elem[E]) IsNotEmpty

func (o Elem[E]) IsNotEmpty() bool

IsNotEmpty returns true if the value is present.

func (Elem[E]) IsPresent

func (o Elem[E]) IsPresent() bool

IsPresent returns true if the value is present.

func (Elem[E]) MustGet

func (o Elem[E]) MustGet() E

MustGet returns the value if present, otherwise panics.

func (Elem[E]) MustGetf

func (o Elem[E]) MustGetf(msg string, args ...any) E

MustGetf returns the value if present, otherwise panics with a custom message.

Jump to

Keyboard shortcuts

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