| 1 | interface Module { |
| 2 | import_() |
| 3 | } |
| 4 | |
| 5 | struct TestModule {} |
| 6 | |
| 7 | fn (mod TestModule) import_() { |
| 8 | println("I'm called!") |
| 9 | } |
| 10 | |
| 11 | fn t_func(a voidptr, b &char) bool { |
| 12 | return true |
| 13 | } |
| 14 | |
| 15 | fn import_module[T]() bool { |
| 16 | $if T !is Module { |
| 17 | println("Type doesn't implement Module.") |
| 18 | return |
| 19 | } |
| 20 | |
| 21 | mod := Module(T{}) |
| 22 | |
| 23 | return t_func(mod.import_, &char(T.name.str)) |
| 24 | } |
| 25 | |
| 26 | fn test_main() { |
| 27 | assert import_module[TestModule]() == true |
| 28 | } |
| 29 |