I have been experimenting with the generics code for a bit and I came across a situation here I wanted to use a generic func as a type
Consider the following:
I have a few sort functions which I want to use for testing and profiling, for this I use something like this
var sortFuncs = []struct {
name string
sFunc func([]int)
}{
{
name: "Quick Sort",
sFunc: sort.Quick,
},
}
Now this sFun inside the struct expects a function with signature func([]nit)
Consider further that we have made changes to these sort functions and now their signature is something like this
func Quick[T constraints.Ordered](arr []T)
How do I make changes to this anonymous struct and sFunc so that they use the new generic func signature?
Thanks!