From 4d7ce9f864409dcfb84d2e027df0022076946583 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 26 Jan 2023 12:52:54 -0700 Subject: Map: Work around https://github.com/golang/go/issues/56548 --- map.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'map.go') diff --git a/map.go b/map.go index 5b53748..6bb1170 100644 --- a/map.go +++ b/map.go @@ -8,7 +8,23 @@ import ( "sync" ) -type Map[K comparable, V any] struct { +// Map is a type-safe equivalent of the standard library's sync.Map. +// +// With versions of Go prior to Go 1.20, Map is specified too loosely, +// as +// +// Map[K any, V any] +// +// while with Go 1.20 and later, Map is specified as +// +// Map[K comparable, V any] +// +// This is because with Go versions prior to 1.20, 'comparable' was +// overly strict, disallowing many types that are valid map-keys (see +// https://github.com/golang/go/issues/56548). The type used as K in +// a Map older versions of Go must be a valid map-key type, even +// though the type specification of Map does not enforce that. +type Map[K mapkey, V any] struct { inner sync.Map } -- cgit v1.2.3-2-g168b