[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <9e23b67e-96b7-4060-9dfd-c7c78f881d63@mailbox.org>
Date: Sat, 27 Jul 2024 08:58:52 -0700
From: Alex Mantel <alexmantel93@...lbox.org>
To: Benno Lossin <benno.lossin@...ton.me>, ojeda@...nel.org,
alex.gaynor@...il.com, wedsonaf@...il.com, boqun.feng@...il.com,
gary@...yguo.net, bjorn3_gh@...tonmail.com, a.hindborg@...sung.com,
aliceryhl@...gle.com, rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] rust: Implement the smart pointer `InPlaceInit` for
`Arc`
Submitted v3:
https://lore.kernel.org/rust-for-linux/20240727042442.682109-1-alexmantel93@mailbox.org/
Thanks for the feedback!
On 25.07.24 11:06, Benno Lossin wrote:
> On 19.07.24 21:22, Alex Mantel wrote:
>> diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs
>> index 68605b633..46f50cf12 100644
>> --- a/rust/kernel/init.rs
>> +++ b/rust/kernel/init.rs
>> @@ -213,6 +213,7 @@
>> use crate::{
>> alloc::{box_ext::BoxExt, AllocError, Flags},
>> error::{self, Error},
>> + sync::Arc,
>> sync::UniqueArc,
>> types::{Opaque, ScopeGuard},
>> };
>> @@ -1112,11 +1113,15 @@ unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
>>
>> /// Smart pointer that can initialize memory in-place.
>> pub trait InPlaceInit<T>: Sized {
>> + /// A type might be pinned implicitly. An addtional `Pin<ImplicitlyPinned>` is useless. In
>> + /// doubt, the type can just be set to `Pin<Self>`.
>
> This comment should better describe the purpose of this associated type,
> the first line could be "Pinned version of `Self`" then (with an empty
> line in between) you could write more explanatory stuff. I would also
> rephrase what you have above, for example: "If a type already implicitly
> pins its pointee, `Pin<Self>` is unnecessary. In this case use `Self`,
> otherwise just use `Pin<Self>`.".
>
>> + type PinnedResult;
>
> I don't really like the name for this, since it is not a result. What do
> you think of `PinnedSelf`?
>
> Otherwise this looks good!
>
> ---
> Cheers,
> Benno
>
>> +
>> /// Use the given pin-initializer to pin-initialize a `T` inside of a new smart pointer of this
>> /// type.
>> ///
>> /// If `T: !Unpin` it will not be able to move afterwards.
>> - fn try_pin_init<E>(init: impl PinInit<T, E>, flags: Flags) -> Result<Pin<Self>, E>
>> + fn try_pin_init<E>(init: impl PinInit<T, E>, flags: Flags) -> Result<Self::PinnedResult, E>
>> where
>> E: From<AllocError>;
>>
>
>
Powered by blists - more mailing lists