Open
Description
Using var _ http.Handler = (*Handler)(nil)
is a great idea to make sure that Handler
implements http.Handler
properly.
What if both the interface and the struct using generic?
For example:
type Score interface {
int64 | float64
}
type ScoreCalculator[T Score] interface {
Add(score T) T
}
type SampleAlgorithm[T Score] struct {}
func (s *SampleAlgorithm[T]) Add(score T) T {
// do some manipulation
return score
}
Should I use both types for verifying compliance?
var _ ScoreCalculator[int64] = (*SampleAlgorithm[int64])(nil)
var _ ScoreCalculator[float64] = (*SampleAlgorithm[float64])(nil)
Metadata
Assignees
Labels
No labels
Activity