github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/kv/predicate/api.go (about) 1 package predicate 2 3 // Key adapts a key appliable predicate to a key\value one 4 func Key[V, K any](predicate func(K) bool) (out func(K, V) bool) { 5 if predicate != nil { 6 out = func(key K, _ V) bool { return predicate(key) } 7 } 8 return 9 } 10 11 // Value adapts a value appliable predicate to a key\value one 12 func Value[K, V any](predicate func(V) bool) (out func(K, V) bool) { 13 if predicate != nil { 14 out = func(_ K, val V) bool { return predicate(val) } 15 } 16 return 17 }