Closed as not planned
Closed as not planned
Description
Proposal Details
The slices
package currently has Collect()
to perform iter.Seq[T] -> []T
, but it doesn't have similar helper functions for collecting the keys or values from an iter.Seq2[K, V]
.
I propose to add the following two functions to slices
:
func CollectKeys[K, V any](seq iter.Seq2[K, V]) []K {
var s []K
for k := range seq {
s = append(s, k)
}
return s
}
func CollectValues[K, V any](seq iter.Seq2[K, V]) []V {
var s []V
for _, v := range seq {
s = append(s, v)
}
return s
}
Metadata
Metadata
Assignees
Type
Projects
Status
Incoming