1 Star 5 Fork 0

xxbiji / go-iterator

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
collect.go 262 Bytes
一键复制 编辑 原始数据 按行查看 历史
xxbiji 提交于 2022-10-28 17:15 . 修改包名
package consumer
import (
"gitee.com/xxbiji/go-iterator/types"
)
func Collect[T any](it types.Iterator) []T {
res := make([]T, 0, 10)
ForEach(it, func(val any) {
v, ok := val.(T)
if !ok {
var t T
v = t
}
res = append(res, v)
})
return res
}
1
https://gitee.com/xxbiji/go-iterator.git
git@gitee.com:xxbiji/go-iterator.git
xxbiji
go-iterator
go-iterator
v0.1.0

搜索帮助

53164aa7 5694891 3bd8fe86 5694891