Source file
test/escape_unique.go
1
2
3
4
5
6
7
8
9 package escape
10
11 import "unique"
12
13 type T string
14
15 func f1(s string) unique.Handle[string] {
16 return unique.Make(s)
17 }
18
19 func f1a(s []byte) unique.Handle[string] {
20 return unique.Make(string(s))
21 }
22
23 func gen[S ~string](s S) unique.Handle[S] {
24 return unique.Make(s)
25 }
26
27 func f2(s T) unique.Handle[T] {
28 return unique.Make(s)
29 }
30
31 func f3(s T) unique.Handle[T] {
32 return gen(s)
33 }
34
35 type pair struct {
36 s1 string
37 s2 string
38 }
39
40 func f4(s1 string, s2 string) unique.Handle[pair] {
41 return unique.Make(pair{s1, s2})
42 }
43
44 type viaInterface struct {
45 s any
46 }
47
48 func f5(s string) unique.Handle[viaInterface] {
49 return unique.Make(viaInterface{s})
50 }
51
52 var sink any
53
54 func f6(s string) unique.Handle[string] {
55 sink = s
56 return unique.Make(s)
57 }
58
59 func f6a(s []byte) unique.Handle[string] {
60 sink = s
61 return unique.Make(string(s))
62 }
63
View as plain text