Re: [PATCH 0/4] rust: a few common Borrow/BorrowMut implementations

From: Alice Ryhl
Date: Mon Jun 02 2025 - 04:49:31 EST


On Sun, Jun 01, 2025 at 12:00:38PM +0900, Alexandre Courbot wrote:
> The Borrow trait has multiple uses, one of them being to store either an
> owned value or a reference to it inside a generic container. This series
> adds these implementations for `Box`, `Arc`, `Vec`, and `CString`. I
> came across the need for this while experimenting with the scatterlist
> abstraction series [1].
>
> This series provides just the `Borrow` and `BorrowMut` implementations,
> but another common use of `Borrow` in the standard library is to use the
> borrowed type for key lookups in collections. For this to work, a few
> consistency traits (`Eq`, `Hash`, and `Ord`) need to be implemented. I
> am not sure whether we want this on kernel types as well, but please let
> me know if we do and I will add them in the next revision.
>
> [1] https://lore.kernel.org/rust-for-linux/DA9JTYA0EQU8.26M0ZX80FOBWY@xxxxxxxxxx/
>
> Signed-off-by: Alexandre Courbot <acourbot@xxxxxxxxxx>

Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>