Skip to content

Commit 7e43600

Browse files
mikdusanandrewrk
authored andcommitted
fix std.rb.Node.getParent to return optional
closes #2962
1 parent d694f29 commit 7e43600

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

std/rb.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ pub const Node = struct {
9393
comptime {
9494
assert(@alignOf(*Node) >= 2);
9595
}
96-
return @intToPtr(*Node, node.parent_and_color & ~mask);
96+
const maybe_ptr = node.parent_and_color & ~mask;
97+
return if (maybe_ptr == 0) null else @intToPtr(*Node, maybe_ptr);
9798
}
9899

99100
fn setColor(node: *Node, color: Color) void {

std/std.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ test "std" {
105105
_ = @import("packed_int_array.zig");
106106
_ = @import("priority_queue.zig");
107107
_ = @import("rand.zig");
108+
_ = @import("rb.zig");
108109
_ = @import("sort.zig");
109110
_ = @import("testing.zig");
110111
_ = @import("thread.zig");

0 commit comments

Comments
 (0)