mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Benno Lossin" <lossin@kernel.org>
To: "Alice Ryhl" <aliceryhl@google.com>, "Miguel Ojeda" <ojeda@kernel.org>
Cc: <rust-for-linux@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] rbtree: rust: add RBTree::is_empty
Date: Tue, 17 Jun 2025 09:30:08 +0200	[thread overview]
Message-ID: <DAOMRPB1PANF.3GPOCH6T8NF80@kernel.org> (raw)
In-Reply-To: <20250616-rbtree-is-empty-v1-1-61f7cfb012e3@google.com>

On Mon Jun 16, 2025 at 12:36 PM CEST, Alice Ryhl 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@google.com>

Reviewed-by: Benno Lossin <lossin@kernel.org>

---
Cheers,
Benno

> ---
>  rust/kernel/rbtree.rs | 6 ++++++
>  1 file changed, 6 insertions(+)

  reply	other threads:[~2025-06-17  7:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-16 10:36 Alice Ryhl
2025-06-17  7:30 ` Benno Lossin [this message]
2025-06-29 19:31 ` Miguel Ojeda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DAOMRPB1PANF.3GPOCH6T8NF80@kernel.org \
    --to=lossin@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®