rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Mantel <alexmantel93@mailbox.org>
To: Benno Lossin <benno.lossin@proton.me>,
	ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com,
	boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com,
	a.hindborg@samsung.com, aliceryhl@google.com,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] rust: Implement the smart pointer `InPlaceInit` for `Arc`
Date: Sat, 27 Jul 2024 08:58:52 -0700	[thread overview]
Message-ID: <9e23b67e-96b7-4060-9dfd-c7c78f881d63@mailbox.org> (raw)
In-Reply-To: <27dad59c-ba8a-43c4-a288-870cf29fa131@proton.me>

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>;
>>
> 
> 

      reply	other threads:[~2024-07-27 15:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-19 19:22 [PATCH v2] rust: Implement the smart pointer `InPlaceInit` for `Arc` Alex Mantel
2024-07-22  9:09 ` Alice Ryhl
2024-07-24 14:19 ` Valentin Obst
2024-07-25 18:06 ` Benno Lossin
2024-07-27 15:58   ` Alex Mantel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9e23b67e-96b7-4060-9dfd-c7c78f881d63@mailbox.org \
    --to=alexmantel93@mailbox.org \
    --cc=a.hindborg@samsung.com \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=wedsonaf@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).