2 Commits

Author SHA1 Message Date
3901e3934f Update go.mod 2024-12-16 19:45:01 +01:00
abeecfd797 added default unmapper functions for OfMap 2024-04-02 19:53:21 +02:00
2 changed files with 14 additions and 2 deletions

4
go.mod
View File

@ -1,5 +1,5 @@
module git.milar.in/milarin/slices
module git.tordarus.net/tordarus/slices
go 1.19
require git.milar.in/milarin/gmath v0.0.3
require git.tordarus.net/tordarus/gmath v0.0.3

12
of.go
View File

@ -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
}