lazy

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OnceFunc added in v0.4.0

func OnceFunc(f func()) func()

OnceFunc port from unreleased std module, sync.OnceFunc

func OnceResult added in v0.4.0

func OnceResult[T any](f func() (T, error)) func() (T, error)

OnceResult port from unreleased std module, sync.OnceValues

func OnceValue added in v0.4.0

func OnceValue[T any](f func() T) func() T

OnceValue port from unreleased std module, sync.OnceValue

func Ternary added in v0.4.0

func Ternary[T any](ok bool, lhs Value[T], rhs Value[T]) T

func TernaryValue added in v0.4.0

func TernaryValue[T any](ok Value[bool], lhs Value[T], rhs Value[T]) T

Types

type LazyCell added in v0.4.0

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

LazyCell is a lazy value.

Which is initialized on the first access.

func NewLazyCell added in v0.4.0

func NewLazyCell[T any](compute func() T) *LazyCell[T]

func (*LazyCell[T]) Get added in v0.4.0

func (self *LazyCell[T]) Get() T

Get forces the evaluation of this lazy value and returns the computed result.

type OnceCell added in v0.3.0

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

OnceCell is a cell which can be written to only once.

func (*OnceCell[T]) Get added in v0.3.0

func (self *OnceCell[T]) Get() optional.Optional[T]

Get return existing one if exists, otherwise panics

func (*OnceCell[T]) GetOrInit added in v0.4.0

func (self *OnceCell[T]) GetOrInit(f func() T) T

GetOrInit return existing one if existed, else create a new then return it

type Value added in v0.4.0

type Value[T any] interface{ Eval() T }

Value is lazy evaluated data

func FuncOf added in v0.4.0

func FuncOf[T any](f func() T) Value[T]

func PtrOf added in v0.4.0

func PtrOf[T any](v *T) Value[T]

func ValueOf added in v0.4.0

func ValueOf[T any](v T) Value[T]

Jump to

Keyboard shortcuts

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