mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 23:52:31 +00:00
378d3e4403
Changed container and initializer syntax * <container> { ... } -> <container> . { ... } * <exrp> { ... } -> <expr> . { ...}
31 lines
521 B
Zig
31 lines
521 B
Zig
const assert = @import("std").debug.assert;
|
|
|
|
const Foo = struct.{
|
|
a: void,
|
|
b: i32,
|
|
c: void,
|
|
};
|
|
|
|
test "compare void with void compile time known" {
|
|
comptime {
|
|
const foo = Foo.{
|
|
.a = {},
|
|
.b = 1,
|
|
.c = {},
|
|
};
|
|
assert(foo.a == {});
|
|
}
|
|
}
|
|
|
|
test "iterate over a void slice" {
|
|
var j: usize = 0;
|
|
for (times(10)) |_, i| {
|
|
assert(i == j);
|
|
j += 1;
|
|
}
|
|
}
|
|
|
|
fn times(n: usize) []const void {
|
|
return ([*]void)(undefined)[0..n];
|
|
}
|