Re: [PATCH v1] rbtree: reduce unsafe blocks on pointer derefs
From: Miguel Ojeda
Date: Mon Jan 19 2026 - 03:21:19 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>
Applied to `rust-next` -- thanks everyone!
[ Alice writes:
"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."
- Miguel ]
[ Reworded title and replaced `cursor_lower_bound()` with
`find_best_match()` in message. - Miguel ]
Cheers,
Miguel