rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alice Ryhl <aliceryhl@google.com>
To: Alex Mantel <alexmantel93@mailbox.org>
Cc: ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com,
	 boqun.feng@gmail.com, gary@garyguo.net,
	bjorn3_gh@protonmail.com,  benno.lossin@proton.me,
	a.hindborg@samsung.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: Mon, 22 Jul 2024 11:09:05 +0200	[thread overview]
Message-ID: <CAH5fLggs=5k0HR2G9XbZ3k-9gjN=CwU_ZHmAbB7zzWj4Lcu+aA@mail.gmail.com> (raw)
In-Reply-To: <20240719192234.330341-1-alexmantel93@mailbox.org>

On Fri, Jul 19, 2024 at 9:22 PM Alex Mantel <alexmantel93@mailbox.org> wrote:
>
> For pinned and unpinned initialization of structs, a trait named
> `InPlaceInit` exists for uniform access. `Arc` did not implement
> `InPlaceInit` yet, although the functions already existed. The main
> reason for that, was that the trait itself returned a `Pin<Self>`. The
> `Arc` implementation of the kernel is already implicitly pinned.
>
> To enable `Arc` to implement `InPlaceInit` and to have uniform access,
> for in-place and pinned in-place initialization, an associated type is
> introduced for `InPlaceInit`. The new implementation of `InPlaceInit`
> for `Arc` sets `Arc` as the associated type. Older implementations use
> an explicit `Pin<T>` as the associated type. The implemented methods for
> `Arc` are mostly moved from a direct implementation on `Arc`. There
> should be no user impact. The implementation for `ListArc` is omitted,
> because it is not merged yet.
>
> Link: https://github.com/Rust-for-Linux/linux/issues/1079
> Signed-off-by: Alex Mantel <alexmantel93@mailbox.org>
> [...]
>  /// 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>`.
> +    type PinnedResult;
> +

It's unfortunate that we can't use an associated type default here.

Reviewed-by: Alice Ryhl <aliceryhl@google.com>

Alice

  reply	other threads:[~2024-07-22  9:09 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 [this message]
2024-07-24 14:19 ` Valentin Obst
2024-07-25 18:06 ` Benno Lossin
2024-07-27 15:58   ` Alex Mantel

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='CAH5fLggs=5k0HR2G9XbZ3k-9gjN=CwU_ZHmAbB7zzWj4Lcu+aA@mail.gmail.com' \
    --to=aliceryhl@google.com \
    --cc=a.hindborg@samsung.com \
    --cc=alex.gaynor@gmail.com \
    --cc=alexmantel93@mailbox.org \
    --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).