Gitly
English
Русский
Español
日本語
中文
Português
Log in
Register
v2
/
vlib
/
v
/
tests
/
generics
/
generic_interface_infer_test.v
20
lines
·
17
sloc
·
268 bytes
·
6488041a749df9762348d019c4223908c476f2e2
Raw
1
struct
Struct[T] {
2
value int
3
x T
4
}
5
6
fn
(s Struct[T]) method() T {
7
return
s.x + s.x
8
}
9
10
interface
Interface[T] {
11
method() T
12
}
13
14
fn
test_infer_generic_interface() {
15
s := Struct[u32]{7, 5}
16
println(s)
17
i := Interface[u32](s)
18
println(i)
19
assert i.method() == 10
20
}
21