pointer

package
v0.0.0-...-ae3a0a2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: MPL-2.0 Imports: 1 Imported by: 0

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

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

Copy returns a new pointer to a.

func Eq

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

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

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