https://www.ardanlabs.com/blog/2020/07/generics-01-basic-syntax.html
https://www.ardanlabs.com/blog/2020/08/generics-02-underlying-types.html
没有范型之前,写通用接口只能用interface的类型推断和反射,效率低
type vector[type T] []T
func (v vector[T]) last() (T, error) {
var zero T
if len(v) == 0 {
return zero, errors.New(“empty”)
}
return v[len(v)-1], nil
}