Re: [PATCH v1] rbtree: reduce unsafe blocks on pointer derefs
From: Alice Ryhl
Date: Wed Jan 14 2026 - 03:42:33 EST
On Thu, Nov 13, 2025 at 3:46 PM Onur Özkan <work@xxxxxxxxxxxxx> wrote:
>
> Refactors parts of the get() and cursor_lower_bound()
> traversal logic to minimize the scope of unsafe blocks
> and avoid duplicating same safety comments.
>
> One of the removed comments was also misleading:
>
> // SAFETY: `node` is a non-null node...
> Ordering::Equal => return Some(unsafe { &(*this).value }),
>
> as `node` should have been `this`.
>
> No functional changes intended; this is purely a safety
> improvement that reduces the amount of unsafe blocks
> while keeping all invariants intact.
>
> Signed-off-by: Onur Özkan <work@xxxxxxxxxxxxx>
One consequence of creating a &_ to the bindings::rb_node struct means
that we assert immutability for the entire struct and not just the
rb_left/rb_right fields, but I have verified that this is ok.
Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>