On Thu, Jan 27, 2022 at 10:00 PM Ian Lance Taylor <i...@golang.org> wrote: > > On Thu, Jan 27, 2022 at 3:13 AM Manlio Perillo <manlio.peri...@gmail.com> > wrote: > > > > On Thursday, January 27, 2022 at 11:42:19 AM UTC+1 Manlio Perillo wrote: > [...] > > Here is an alternate implementation: > > https://gotipplay.golang.org/p/mGm8DkqkuAX > > > > The code **seems** reasonable, but the compiler reports an error: > > ./prog.go:24:12: *MyStruct does not implement structField > > I believe that that error message is correct. The constraint is for > any type whose underlying type is "*struct{ x int }". The code is > trying to instantiate with the type *MyStruct. The underlying type of > *MyStruct is *MyStruct. It is not *struct{ x int }. So the type > argument does not match the constraint. >
However (from the first example) MyStruct matches struct {x int }. It seems a bit confusing that *MyStruct does not match *struct {x int }. Thanks Manlio -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAAToxAFw208jwp_9CatBtD43OEPRQWy4i7m2zt8Lro5Zoj%3DMCw%40mail.gmail.com.