mirror of
https://github.com/ziglang/zig.git
synced 2024-12-03 10:28:48 +00:00
2e15a404e2
* bitcast treats all pointers as pointers * correctly unwrapping error unions with pointers * equality operators for primitive optional types
24 lines
545 B
Zig
24 lines
545 B
Zig
const std = @import("std");
|
|
const testing = std.testing;
|
|
const expect = testing.expect;
|
|
const expectEqual = testing.expectEqual;
|
|
|
|
test "self-referential struct through a slice of optional" {
|
|
const S = struct {
|
|
const Node = struct {
|
|
children: []?Node,
|
|
data: ?u8,
|
|
|
|
fn new() Node {
|
|
return Node{
|
|
.children = undefined,
|
|
.data = null,
|
|
};
|
|
}
|
|
};
|
|
};
|
|
|
|
var n = S.Node.new();
|
|
try expect(n.data == null);
|
|
}
|