Rust generic has a “Self” which is the Concrete type of the instantiated Generic type. Is there an equivalent in Go?
Specifically, so i can get Clone() to return a Self. Then i can have generic struct which will implement the Clone interface.
Something like,
type Cloner[T any] interface {
Clone() T
}
type Parent[T any] struct {
parentAttr T
Cloner[Self]
}
func (p Parent[T]) Clone() Parent[T] { return a clone of the parent obj }
type Child[T any] struct {
Parent[T]
childAttr string
}
func (c Child[T]) Clone() Child[T] { return a clone of the child obj }