1
0
mirror of https://github.com/golang/go synced 2024-11-15 11:10:22 -07:00
go/doc/next/6-stdlib/2-unique.md

14 lines
566 B
Markdown
Raw Normal View History

### New unique package
The new [unique] package provides facilities for
canonicalizing values (like "interning" or "hash-consing").
Any value of comparable type may be canonicalized with the new
`Make[T]` function, which produces a reference to a canonical copy of
the value in the form of a `Handle[T]`.
Two `Handle[T]` are equal if and only if the values used to produce the
handles are equal, allowing programs to deduplicate values and reduce
their memory footprint.
Comparing two `Handle[T]` values is efficient, reducing down to a simple
pointer comparison.