github.com/traefik/yaegi@v0.15.1/_test/gen5.go (about) 1 package main 2 3 import "fmt" 4 5 type Set[Elem comparable] struct { 6 m map[Elem]struct{} 7 } 8 9 func Make[Elem comparable]() Set[Elem] { 10 return Set[Elem]{m: make(map[Elem]struct{})} 11 } 12 13 func (s Set[Elem]) Add(v Elem) { 14 s.m[v] = struct{}{} 15 } 16 17 func main() { 18 s := Make[int]() 19 s.Add(1) 20 fmt.Println(s) 21 } 22 23 // Output: 24 // {map[1:{}]}