3 // Copyright 2021 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
11 func f[T any](i interface{}) {
12 switch x := i.(type) {
18 fmt.Println("int32/int16", x)
19 case struct{ a, b T }:
20 fmt.Println("struct{T,T}", x.a, x.b)
22 fmt.Println("other", x)
26 f[float64](float64(6))
29 f[float64](struct{ a, b float64 }{a: 1, b: 2})
34 f[interface{ M() }](int(11))