Re: [PATCH v3 03/12] rust: xarray: add `contains_index` method
From: Tamir Duberstein
Date: Wed Feb 11 2026 - 13:25:16 EST
On Tue, Feb 10, 2026 at 11:31 PM Andreas Hindborg <a.hindborg@xxxxxxxxxx> wrote:
>
> Tamir Duberstein <tamird@xxxxxxxxx> writes:
>
> > On Mon, Feb 9, 2026 at 6:38 AM Andreas Hindborg <a.hindborg@xxxxxxxxxx> wrote:
> >>
> >> Add a convenience method `contains_index` to check whether an element
> >> exists at a given index in the XArray. This method provides a more
> >> ergonomic API compared to calling `get` and checking for `Some`.
> >>
> >> Signed-off-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
> >
> > As I said in v1 I'm -1 on this change. As gregkh would say: it's hard
> > to review a new API without seeing its user.
>
> I already gave you the user inline [1] and if you wish you can also see
> it in a downstream tree [2]. Gary already explained why this is required
> with the current implementation of the borrow checker [3].
Yeah, that's fine, and the poor ergonomics are IMO a feature - I
should see the ugly `is_some()` call in your code, because it's a
useful signal that something non-obvious is going. This function hides
that, which I think is not better.
>
> Best regards,
> Andreas Hindborg
>
> [1] https://lore.kernel.org/r/87344gh2pk.fsf@xxxxxxxxx-host-address-is-not-set
> [2] https://github.com/metaspace/linux/blob/aa43a6ecb68a785a90e167609aa57c5a0860d123/drivers/block/rnull/disk_storage.rs#L218
> [3] https://lore.kernel.org/r/DFK801ZCI1GD.34GWJ10JZBBBF@xxxxxxxxxxx
>