rust: sync: implement `Borrow` and `BorrowMut` for `Arc` types
authorAlexandre Courbot <acourbot@nvidia.com>
Mon, 16 Jun 2025 03:34:06 +0000 (12:34 +0900)
committerMiguel Ojeda <ojeda@kernel.org>
Thu, 3 Jul 2025 18:46:29 +0000 (20:46 +0200)
commit2009a2d5696944d85c34d75e691a6f3884e787c0
tree8892a6da03907f76be9795c8281e6b3c6c06c2a2
parentd6763e0abb43d550791eb66d2b91e82cb29807f9
rust: sync: implement `Borrow` and `BorrowMut` for `Arc` types

Implement `Borrow<T>` and `BorrowMut<T>` for `UniqueArc<T>`, and
`Borrow<T>` for `Arc<T>`. This allows these containers to be used in
generic APIs asking for types implementing those traits. `T` and `&mut
T` also implement those traits allowing users to use either owned,
shared or borrowed values.

`ForeignOwnable` makes a call to its own `borrow` method which must be
disambiguated.

Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://lore.kernel.org/r/20250616-borrow_impls-v4-2-36f9beb3fe6a@nvidia.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/kernel/sync/arc.rs