ptr

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare added in v0.4.0

func Compare[T cmp.Ordered](l, r *T) int

Compare compares two pointer. If both non-nil, compare underlying data, if both nil, return 0, non-nil pointer is always greater than nil pointer.

func CompareBy added in v0.4.0

func CompareBy[T any](l, r *T, cmp func(T, T) int) int

func Equal added in v0.4.0

func Equal[T comparable](l, r *T) bool

Equal test whether two pointer are equal. If both non-nil, test underlying data, if both nil, return true, else return false

func EqualBy added in v0.4.0

func EqualBy[T any](l, r *T, eq func(T, T) bool) bool

func OrZero added in v0.5.0

func OrZero[T any](v *T) *T

func Ref

func Ref[T any](t T) *T

Ref return reference of value

func RefOrNil added in v0.4.0

func RefOrNil[T comparable](t T) *T

RefOrNil return reference of value if it not the zero value, else return nil

func ValueOr added in v0.4.0

func ValueOr[T any](v *T, d T) T

ValueOr return value of pointer if not nil, else return default value.

func ValueOrZero added in v0.4.0

func ValueOrZero[T any](v *T) T

ValueOrZero return value of pointer if not nil, else return zero value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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