mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
21 lines
263 B
V
21 lines
263 B
V
struct Struct<T> {
|
|
value int
|
|
x T
|
|
}
|
|
|
|
fn (s Struct<T>) method() T {
|
|
return s.x + s.x
|
|
}
|
|
|
|
interface Interface<T> {
|
|
method() T
|
|
}
|
|
|
|
fn test_infer_generic_interface() {
|
|
s := Struct<u32>{7, 5}
|
|
println(s)
|
|
i := Interface(s)
|
|
println(i)
|
|
assert i.method() == 10
|
|
}
|