Re: [go-nuts] Is there a way to eliminate the code repetition in the code?

2022-03-20 Thread Ian Lance Taylor
I don't think so. https://go.googlesource.com/proposal/+/refs/heads/master/design/43651-type-parameters.md#no-way-to-express-convertibility Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving

[go-nuts] Is there a way to eliminate the code repetition in the code?

2022-03-20 Thread tapi...@gmail.com
package main type A interface { Ma() } type B interface { Mb() } type Ta struct { A } type Tb struct { B } func ConvertSliceToA[From A](vs []From) []A { var r = make([]A, len(vs)) for i := range vs { r[i] = vs[i] } return r }