I am trying to do structural typing with a generic type to implement an interface as shown
package main
type Queue[T comparable] struct {
elements []T
}
type QueueOperations[T comparable] interface {
Push(e T)
Pop() T
Len() int
}
var _ QueueOperations = (*Queue)(nil)
func main() {
}
I see I can't do that, as it is giving me a WrongTypeArgcount
error "cannot use generic type QueueOperations[T comparable] without instantiation".
What is the right way to achieve this?
var _ QueueOperations[int] = (*Queue[int])(nil)
– Lemmie