Given there's a generic interface:
type Packet interface { Content() int } type Recycler[T any] interface { 
Get() *T } 

and their implementation:
type packet struct { content int } type BaseRecycler[T any] struct { t T } 

its impossible to convert the implementation to the interface:
r := &BaseRecycler[packet]{} r1 := r.(Recycler[Packet]) 
fmt.Println(r3.Get().Content()) // compile error: Unresolved reference 
'Content' 

here is a live code example: https://go.dev/play/p/qbnYfyDd22A

The error is because the Packet interface align with the *packet instead of 
packet. Could anyone suggest how to handle this?

-- 
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 visit 
https://groups.google.com/d/msgid/golang-nuts/45934894-f893-4707-b784-8db23ebaced2n%40googlegroups.com.

Reply via email to