mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-25 17:52:02 +02:00
Add a generic Values()
This commit is contained in:
@@ -98,3 +98,15 @@ func Keys[M ~map[K]V, K comparable, V any](m M) []K {
|
|||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Values returns the values of the map m.
|
||||||
|
// The values will be an indeterminate order.
|
||||||
|
func Values[M ~map[K]V, K comparable, V any](m M) []V {
|
||||||
|
r := make([]V, len(m))
|
||||||
|
i := 0
|
||||||
|
for _, v := range m {
|
||||||
|
r[i] = v
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user