optional

package
v3.0.0-alpha2.104 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var False = NewBool(false)

False is a Bool set to false.

View Source
var True = NewBool(true)

True is a Bool set to true.

Functions

This section is empty.

Types

type Bool

type Bool = Var[bool]

Bool is an optional bool value.

func NewBool

func NewBool(val bool) Bool

NewBool creates a new Bool with the given value.

type Var

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

Var is a generic optional value that tracks whether it has been set.

func NewVar

func NewVar[T any](val T) Var[T]

NewVar creates a new Var with the given value, marked as set.

func (*Var[T]) Get

func (v *Var[T]) Get() T

Get returns the value, or the zero value if unset.

func (*Var[T]) IsSet

func (v *Var[T]) IsSet() bool

IsSet reports whether a value has been assigned.

func (*Var[T]) Set

func (v *Var[T]) Set(val T)

Set assigns a value and marks the variable as set.

func (*Var[T]) Unset

func (v *Var[T]) Unset()

Unset resets the variable to the zero value and marks it as unset.

Jump to

Keyboard shortcuts

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