pointer

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: MIT Imports: 1 Imported by: 33

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstOrZero

func FirstOrZero[T any](t []T) T

FirstOrZero returns the first value of a slice or the zero slice if slize is empty.

func IsZero

func IsZero[T any](t T) bool

IsZero returns true if the passed value equals its zero value.

func Pointer

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

Pointer returns the pointer of the given value.

func PointerOrDefault

func PointerOrDefault[T any](t T, defaultValue T) *T

PointerOrDefault returns the pointer of the given value. If the given value is equal to the zero value, the pointer of the default value will be returned instead.

func PointerOrNil

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

PointerOrNil returns the pointer of the given value or nil if given value is equal to zero value.

func SafeDeref

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

SafeDeref returns the value from the passed pointer or zero value for a nil pointer.

func SafeDerefOrDefault

func SafeDerefOrDefault[T any](t *T, defaultValue T) T

SafeDerefOrDefault returns the value from the passed pointer or the default value for a nil pointer or zero value.

func WrapInSlice

func WrapInSlice[T any](t T) []T

FirstOrZero returns a slice that wraps the given value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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