提问人:404 提问时间:7/23/2023 最后编辑:404 更新时间:7/27/2023 访问量:105
如何实例化 Golang 泛型类型 从反射类型播种它
How to Instantiate Golang Generic Type Seeding it From Reflect Type
问:
具有通用界面
type G[T any] interface {
...
}
和 ,如何实例化另一个实际上表示reflect.Type
t
reflect.Type
G[t]
最终,它应该与它自己相匹配t
G[t]
func ImplementsG(t reflect.Type) bool {
var gType reflect.Type = ... // get Type of exact interface G[of exact t]
return t.Implements(gType)
}
答: 暂无答案
评论
G[T any]
exact G[exact t]
func Clone[T any](value T) T
Cloneable[T]
func(t T) Clone() T
interface{}