v2 / vlib / v / tests / skip_unused / generics_method.vv
31 lines · 27 sloc · 360 bytes · e12ba2b67e2cae2c06ab407bb8bc3e4d56548dc3
Raw
1interface Something {
2 i int
3}
4
5struct Some {
6 i int
7}
8
9struct App[M] {
10 f M
11}
12
13fn (mut self App[M]) next[M, T](_input T) f64 {
14 $if M is Something {
15 return 0
16 } $else {
17 panic('${typeof(M.typ).name} is not supported')
18 return 1
19 }
20 return 1
21}
22
23fn main() {
24 mut app := App[Some]{
25 f: Some{
26 i: 10
27 }
28 }
29 assert app.next(1) == 0
30 println(app.next(1))
31}
32