On Wed, 13 Jan 2021 at 20:38, Marcus Manning <icons...@gmail.com> wrote:
> > Regarding the the section of No parameterized methods in go generics > draft: > > package p1 // S is a type with a parameterized method Identity. type S > struct{} // Identity is a simple identity method that works for any type. > func (S) Identity[T any](v T) T { return v } package p2 // HasIdentity is > an interface that matches any type with a // parameterized Identity method. > type HasIdentity interface { Identity[T any](T) T } package p3 import "p2" > // CheckIdentity checks the Identity method if it exists. // Note that > although this function calls a parameterized method, // this function is > not itself parameterized. func CheckIdentity(v interface{}) { if vi, ok := > v.(p2.HasIdentity); ok { if got := vi.Identity[int](0); got != 0 { > panic(got) } } } package p4 import ( "p1" "p3" ) // CheckSIdentity passes > an S value to CheckIdentity. func CheckSIdentity() { p3.CheckIden > This code seems corrupted (no newlines) and incomplete. It's hard to understand what your question is about without seeing the motivational code. -- 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/CAJhgacg%2B3epUowNnpRHB_b89qXc%3Ded%2BSiHQLjaPahMUns%2BivZA%40mail.gmail.com.