aboutsummaryrefslogtreecommitdiff
path: root/test/typeparam/index.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/typeparam/index.go')
-rw-r--r--test/typeparam/index.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/test/typeparam/index.go b/test/typeparam/index.go
index 83e65acdd0..cb9b2613c3 100644
--- a/test/typeparam/index.go
+++ b/test/typeparam/index.go
@@ -11,7 +11,7 @@ import (
)
// Index returns the index of x in s, or -1 if not found.
-func index[T comparable](s []T, x T) int {
+func Index[T comparable](s []T, x T) int {
for i, v := range s {
// v and x are type T, which has the comparable
// constraint, so we can use == here.
@@ -30,17 +30,17 @@ func main() {
want := 2
vec1 := []string{"ab", "cd", "ef"}
- if got := index(vec1, "ef"); got != want {
+ if got := Index(vec1, "ef"); got != want {
panic(fmt.Sprintf("got %d, want %d", got, want))
}
vec2 := []byte{'c', '6', '@'}
- if got := index(vec2, '@'); got != want {
+ if got := Index(vec2, '@'); got != want {
panic(fmt.Sprintf("got %d, want %d", got, want))
}
vec3 := []*obj{&obj{2}, &obj{42}, &obj{1}}
- if got := index(vec3, vec3[2]); got != want {
+ if got := Index(vec3, vec3[2]); got != want {
panic(fmt.Sprintf("got %d, want %d", got, want))
}
}