1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-11-25 22:21:49 +02:00
Files
fp-go/record/generic/eq.go

25 lines
470 B
Go
Raw Normal View History

package generic
import (
E "github.com/IBM/fp-go/eq"
)
func equals[M ~map[K]V, K comparable, V any](left, right M, eq func(V, V) bool) bool {
if len(left) != len(right) {
return false
}
for k, v1 := range left {
if v2, ok := right[k]; !ok || !eq(v1, v2) {
return false
}
}
return true
}
func Eq[M ~map[K]V, K comparable, V any](e E.Eq[V]) E.Eq[M] {
eq := e.Equals
return E.FromEquals(func(left, right M) bool {
return equals(left, right, eq)
})
}