pointer

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 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 Equals method.

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 // just so happens to be the types we want
}

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