Re: [PATCH] rbtree: rust: add RBTree::is_empty
From: Miguel Ojeda
Date: Sun Jun 29 2025 - 15:31:50 EST
On Mon, Jun 16, 2025 at 12:36 PM Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote:
>
> In Rust Binder I need to be able to determine whether a red/black tree
> is empty. Thus, add a method for that operation to replace
>
> rbtree.iter().next().is_none()
>
> This is terrible, so add a method for this purpose. We do not add a
> RBTree::len method because computing the number of elements requires
> iterating the entire tree, but checking whether it is empty can be done
> cheaply.
>
> Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
Applied to `rust-next` -- thanks everyone!
[ Adjusted title. - Miguel ]
Cheers,
Miguel