From abeecfd797087f7cca628b77d27c1c94c7838a1b Mon Sep 17 00:00:00 2001 From: milarin Date: Tue, 2 Apr 2024 19:53:21 +0200 Subject: [PATCH] added default unmapper functions for OfMap --- of.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/of.go b/of.go index d8f12cf..df2f912 100644 --- a/of.go +++ b/of.go @@ -14,3 +14,15 @@ func OfMap[K comparable, V, T any](m map[K]V, unmapper func(K, V) T) []T { } return out } + +// UnmapKey is an unmapper function which returns the map key only +// and discards its value. It is supposed to be used with OfMap +func UnmapKey[K comparable, V any](key K, _ V) K { + return key +} + +// UnmapValue is an unmapper function which returns the map value only +// and discards its key. It is supposed to be used with OfMap +func UnmapValue[K comparable, V any](_ K, value V) V { + return value +}