Re: [PATCH 4/4] rust: xarray: Add Guard::find() helper

Alvin Sun
2026-04-17T02:17:28Z

On 4/17/26 09:18, Matthew Wilcox wrote:
> On Fri, Apr 17, 2026 at 09:05:54AM +0800, Alvin Sun wrote:
>> Add a helper to find the first present entry in the XArray.
> Why would you expose a function which does striclty less than the
> underlying C implementation, rather than exposing all the functionality
> that xa_find does?
>
>> Returns the index of the first present entry, or None if the array
>> is empty.
> Why not return the value found, like xa_find() does?

Hi Matthew,

Thanks for the feedback! I had considered both returning a tuple (key,
&value)
and an Entry struct, but only returned the key since that's all Tyr
currently
needs. I'll look at other Rust code to see which approach fits better, then
implement it properly in v2.

Best regards,
Alvin

>
> This is all very troubling. I don't think Rust should depart from
> what C has without good reason.
>