| 1 | #include "@VMODROOT/iterator.h" |
| 2 | |
| 3 | struct C.MyCStruct { |
| 4 | mut: |
| 5 | x int |
| 6 | } |
| 7 | |
| 8 | fn (mut self C.MyCStruct) next() ?int { |
| 9 | if self.x >= 10 { |
| 10 | return none |
| 11 | } |
| 12 | self.x++ |
| 13 | return self.x |
| 14 | } |
| 15 | |
| 16 | fn test_iterating_over_cstructs() { |
| 17 | iter := C.MyCStruct{} |
| 18 | for x in iter { |
| 19 | println(x) |
| 20 | assert true |
| 21 | } |
| 22 | } |
| 23 |