[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DDGHGF4XOJQG.2MVGBMPK0KUQE@kernel.org>
Date: Sun, 12 Oct 2025 18:26:54 +0200
From: "Benno Lossin" <lossin@...nel.org>
To: "Markus Probst" <markus.probst@...teo.de>, "Danilo Krummrich"
<dakr@...nel.org>, "Miguel Ojeda" <ojeda@...nel.org>, "Alex Gaynor"
<alex.gaynor@...il.com>, "Lee Jones" <lee@...nel.org>, "Pavel Machek"
<pavel@...nel.org>
Cc: "Lorenzo Stoakes" <lorenzo.stoakes@...cle.com>, "Vlastimil Babka"
<vbabka@...e.cz>, "Liam R. Howlett" <Liam.Howlett@...cle.com>, "Uladzislau
Rezki" <urezki@...il.com>, "Boqun Feng" <boqun.feng@...il.com>, "Gary Guo"
<gary@...yguo.net>, <bjorn3_gh@...tonmail.com>, "Andreas Hindborg"
<a.hindborg@...nel.org>, "Alice Ryhl" <aliceryhl@...gle.com>, "Trevor
Gross" <tmgross@...ch.edu>, <rust-for-linux@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <linux-leds@...r.kernel.org>
Subject: Re: [PATCH v4 1/2] rust: add basic Pin<Vec<T, A>> abstractions
On Sun Oct 12, 2025 at 4:52 PM CEST, Markus Probst wrote:
> @@ -109,6 +111,21 @@ pub struct Vec<T, A: Allocator> {
> _p: PhantomData<A>,
> }
>
> +/// Extension for Pin<Vec<T, A>>
> +pub trait PinnedVecExt<T> {
Why is this an extension trait? Couldn't we directly implement this on
`Vec<T>` with `self: Pin<&mut Self>`?
---
Cheers,
Benno
> + /// Pin-initializes P and appends it to the back of the [`Vec`] instance without reallocating.
> + fn push_pin_init<E: From<PushError<P>>, P: PinInit<T, E>>(&mut self, init: P) -> Result<(), E>;
> +
> + /// Shortens the vector, setting the length to `len` and drops the removed values.
> + /// If `len` is greater than or equal to the current length, this does nothing.
> + ///
> + /// This has no effect on the capacity and will not allocate.
> + fn truncate(&mut self, len: usize);
> +
> + /// Removes the last element from a vector and drops it returning true, or false if it is empty.
> + fn pop(&mut self) -> bool;
> +}
> +
> /// Type alias for [`Vec`] with a [`Kmalloc`] allocator.
> ///
> /// # Examples
Powered by blists - more mailing lists