| 1 | const std = @import("std"); |
| 2 | const expectEqual = std.testing.expectEqual; |
| 3 | |
| 4 | test "@This()" { |
| 5 | var items = [_]i32{ 1, 2, 3, 4 }; |
| 6 | const list = List(i32){ .items = items[0..] }; |
| 7 | try expectEqual(4, list.length()); |
| 8 | } |
| 9 | |
| 10 | fn List(comptime T: type) type { |
| 11 | return struct { |
| 12 | const Self = @This(); |
| 13 | |
| 14 | items: []T, |
| 15 | |
| 16 | fn length(self: Self) usize { |
| 17 | return self.items.len; |
| 18 | } |
| 19 | }; |
| 20 | } |
| 21 | |
| 22 | // test |