fix std.rb.Node.getParent to return optional

closes #2962
This commit is contained in:
Michael Dusan 2019-07-28 08:38:11 -04:00 committed by Andrew Kelley
parent d694f298d8
commit 7e436006be
2 changed files with 3 additions and 1 deletions

View File

@ -93,7 +93,8 @@ pub const Node = struct {
comptime {
assert(@alignOf(*Node) >= 2);
}
return @intToPtr(*Node, node.parent_and_color & ~mask);
const maybe_ptr = node.parent_and_color & ~mask;
return if (maybe_ptr == 0) null else @intToPtr(*Node, maybe_ptr);
}
fn setColor(node: *Node, color: Color) void {

View File

@ -105,6 +105,7 @@ test "std" {
_ = @import("packed_int_array.zig");
_ = @import("priority_queue.zig");
_ = @import("rand.zig");
_ = @import("rb.zig");
_ = @import("sort.zig");
_ = @import("testing.zig");
_ = @import("thread.zig");