bumped up golang version to 1.23

This commit is contained in:
2025-06-22 19:35:57 +02:00
parent efc99a9658
commit cc2ead6c4e
11 changed files with 68 additions and 30 deletions

8
of.go
View File

@ -4,10 +4,10 @@ func Of[T any](values ...T) []T {
return values
}
// OfMap returns a slice containing the return values of the unmapper function
// OfMap returns a slice containing the return values of the Unmapper
// applied to any key-value pair in m
// The order is random
func OfMap[K comparable, V, T any](m map[K]V, unmapper func(K, V) T) []T {
func OfMap[K comparable, V, T any](m map[K]V, unmapper MapUnmapper[K, V, T]) []T {
out := make([]T, 0, len(m))
for k, v := range m {
out = append(out, unmapper(k, v))
@ -15,13 +15,13 @@ 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
// UnmapKey is an Unmapper 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
// UnmapValue is an Unmapper 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