From 0a23c4a5a4bcde56bed78709b92243b544a04995 Mon Sep 17 00:00:00 2001 From: surdeus Date: Fri, 25 Nov 2022 19:12:25 +0500 Subject: [PATCH] ... --- src/cmd/test/main.go | 4 ++-- src/slicex/main.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cmd/test/main.go b/src/cmd/test/main.go index 3055a0c..588b1ce 100644 --- a/src/cmd/test/main.go +++ b/src/cmd/test/main.go @@ -30,8 +30,8 @@ func main() { fmt.Println(m) fmt.Println(slicex.MakeMap( s, - func(v Struct) string { - return v.Name + func(s []Struct, i int) string { + return s[i].Name }, )) diff --git a/src/slicex/main.go b/src/slicex/main.go index 0e4f457..369f9b6 100644 --- a/src/slicex/main.go +++ b/src/slicex/main.go @@ -2,14 +2,14 @@ package slicex func MakeMap[K comparable, V any]( values []V, - fn func(V) (K), + fn func([]V, int) (K), ) map[K] V { var k K r := make(map[K] V) - for _, v := range values { - k = fn(v) - r[k] = v + for i, _ := range values { + k = fn(values, i) + r[k] = values[i] } return r