value

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package value provides value-first conditional selection. Use this for selecting a value with a fallback, not for executing branches of logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cond

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

Cond holds a value pending a condition check.

func Of

func Of[T any](t T) Cond[T]

Of wraps a value for conditional selection.

func (Cond[T]) When

func (c Cond[T]) When(ok bool) option.Basic[T]

When returns an option: Ok(value) if condition true, NotOk if false.

type LazyCond

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

LazyCond holds a function for deferred value computation.

func OfCall

func OfCall[T any](fn func() T) LazyCond[T]

OfCall wraps a function for lazy conditional selection. The function is only called if the condition is true.

func (LazyCond[T]) When

func (c LazyCond[T]) When(ok bool) option.Basic[T]

When evaluates fn only if condition true, returns option.

Jump to

Keyboard shortcuts

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