Re: [PATCH 08/22] rust: pin-init: move `InPlaceInit` and impls of `InPlaceWrite` into the kernel crate
From: Benno Lossin
Date: Wed Mar 05 2025 - 07:07:09 EST
On Wed Mar 5, 2025 at 12:18 PM CET, Andreas Hindborg wrote:
> "Benno Lossin" <benno.lossin@xxxxxxxxx> writes:
>
>> In order to make pin-init a standalone crate, move kernel-specific code
>> directly into the kernel crate. This includes the `InPlaceInit<T>`
>> trait, its implementations and the implementations of `InPlaceWrite` for
>> `Arc` and `UniqueArc`. All of these use the kernel's error type which
>> will become unavailable in pin-init.
>>
>> Signed-off-by: Benno Lossin <benno.lossin@xxxxxxxxx>
>> ---
>> rust/kernel/alloc/kbox.rs | 3 +-
>> rust/kernel/init.rs | 55 +++++++++++++++++
>> rust/kernel/prelude.rs | 3 +-
>> rust/kernel/sync/arc.rs | 65 +++++++++++++++++++-
>> rust/pin-init/src/lib.rs | 125 ++------------------------------------
>> 5 files changed, 127 insertions(+), 124 deletions(-)
>>
>
> [...]
>
>> --- a/rust/pin-init/src/lib.rs
>> +++ b/rust/pin-init/src/lib.rs
>> @@ -10,7 +10,7 @@
>> //! To initialize a `struct` with an in-place constructor you will need two things:
>> //! - an in-place constructor,
>> //! - a memory location that can hold your `struct` (this can be the [stack], an [`Arc<T>`],
>> -//! [`UniqueArc<T>`], [`KBox<T>`] or any other smart pointer that implements [`InPlaceInit`]).
>> +//! [`KBox<T>`] or any other smart pointer that supports this library).
>
> Would you not want to remove references to `KBox` here as well? Even
> though you don't have to move the impl, I don't imagine `KBox` exist in
> user space?
Yes, this is done in "rust: pin-init: fix documentation links".
---
Cheers,
Benno