ptr

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Coalesce

func Coalesce[T any](ptrs ...*T) *T

Coalesce returns the first non-nil pointer, or nil if all are nil.

func Equal

func Equal[T comparable](a, b *T) bool

Equal compares two pointers by value. Both nil returns true, one nil returns false.

func Of

func Of[T comparable](v T) *T

Of returns a pointer to v, or nil if v is the zero value.

func Value

func Value[T any](p *T, fallbacks ...*T) T

Value dereferences a pointer, returning its value. If p is nil, it tries each fallback pointer in order. If all are nil, the zero value of T is returned.

func ValueOrElse

func ValueOrElse[T any](p *T, fn func() T) T

ValueOrElse dereferences a pointer, calling fn to produce a fallback if nil.

func Zero

func Zero[T any]() T

Zero returns the zero value of type T.

Types

This section is empty.

Jump to

Keyboard shortcuts

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