| 1 | module main |
| 2 | |
| 3 | struct ParserResult[I, O] { |
| 4 | i []I |
| 5 | o []O |
| 6 | } |
| 7 | |
| 8 | type TCount = u32 |
| 9 | |
| 10 | fn (count TCount) take_part[I, O](i []I) !ParserResult[I, O] { |
| 11 | if i.len < count { |
| 12 | return error('error1') |
| 13 | } |
| 14 | return ParserResult{ |
| 15 | i: i[count..] |
| 16 | o: i[..count] |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | fn (count TCount) print_part[T](v T) { |
| 21 | _ = v |
| 22 | } |
| 23 | |
| 24 | fn main() { |
| 25 | _ = [TCount(4).take_part] |
| 26 | f := TCount(4).print_part |
| 27 | _ = f |
| 28 | } |
| 29 |