unique

package standard library
go1.23.3 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: BSD-3-Clause Imports: 7 Imported by: 42

Documentation

Overview

The unique package provides facilities for canonicalizing ("interning") comparable values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handle

type Handle[T comparable] struct {
	// contains filtered or unexported fields
}

Handle is a globally unique identity for some value of type T.

Two handles compare equal exactly if the two values used to create the handles would have also compared equal. The comparison of two handles is trivial and typically much more efficient than comparing the values used to create them.

func Make

func Make[T comparable](value T) Handle[T]

Make returns a globally unique handle for a value of type T. Handles are equal if and only if the values used to produce them are equal.

func (Handle[T]) Value

func (h Handle[T]) Value() T

Value returns a shallow copy of the T value that produced the Handle.

Jump to

Keyboard shortcuts

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