pointer

package
v1.5.6 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: MPL-2.0 Imports: 1 Imported by: 27

Documentation

Overview

Package pointer provides helper functions related to Go pointers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy added in v1.2.12

func Copy[A any](a *A) *A

Copy returns a new pointer to a.

func Eq added in v1.2.12

func Eq[P Primitive](a, b *P) bool

Eq returns whether a and b are equal in underlying value.

May only be used on pointers to primitive types, where the comparison is guaranteed to be sensible. For complex types (i.e. structs) consider implementing an Equal method.

func Merge added in v1.2.16

func Merge[P Primitive](previous, next *P) *P

Merge will return Copy(next) if next is not nil, otherwise return Copy(previous).

func Of

func Of[A any](a A) *A

Of returns a pointer to a.

Types

type Primitive added in v1.2.12

type Primitive interface {
	constraints.Ordered | bool
}

Primitive represents basic types that are safe to do basic comparisons by pointer dereference (checking nullity first).

Jump to

Keyboard shortcuts

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