mirror of
https://github.com/ziglang/zig.git
synced 2024-11-26 23:22:44 +00:00
16 lines
285 B
Zig
16 lines
285 B
Zig
fn List(comptime T: type) type {
|
|
return struct {
|
|
items: []T,
|
|
len: usize,
|
|
};
|
|
}
|
|
|
|
// The generic List data structure can be instantiated by passing in a type:
|
|
var buffer: [10]i32 = undefined;
|
|
var list = List(i32){
|
|
.items = &buffer,
|
|
.len = 0,
|
|
};
|
|
|
|
// syntax
|