cmd/go2go: use predeclared comparable in maps test

(But embedding comparable doesn't work yet.)

Change-Id: I977ca97597de47c79edb56b385c970392afb87f0
This commit is contained in:
Ian Lance Taylor 2020-03-11 17:52:17 -07:00 committed by Robert Griesemer
parent 10b59aa539
commit 2044d8b94b
1 changed files with 11 additions and 9 deletions

View File

@ -5,13 +5,6 @@
// Package maps implements simple functions to manipulate maps in various ways.
package maps
contract comparable(T) {
T int, int8, int16, int32, int64,
uint, uint8, uint16, uint32, uint64, uintptr,
float32, float64,
string
}
// Keys returns the keys of the map m.
// The keys will be an indeterminate order.
func Keys(type K, V comparable(K))(m map[K]V) []K {
@ -33,8 +26,17 @@ func Values(type K, V comparable(K))(m map[K]V) []V {
}
contract twocomparable(K, V) {
comparable(K)
comparable(V)
// Should be
// comparable(K)
// comparable(V)
K int, int8, int16, int32, int64,
uint, uint8, uint16, uint32, uint64, uintptr,
float32, float64,
string
V int, int8, int16, int32, int64,
uint, uint8, uint16, uint32, uint64, uintptr,
float32, float64,
string
}
// Equal reports whether two maps contain the same key/value pairs.