lkml.org 
[lkml]   [2024]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/2] rust: init: add re-initialization functions
On Thu, 25 Apr 2024 21:34:44 +0000
Benno Lossin <benno.lossin@proton.me> wrote:

> Sometimes it is necessary to split allocation and initialization into
> two steps. One such situation is when reusing existing allocations
> obtained via `Box::drop_contents`. See [1] for an example.
> In order to support this use case add `re_[pin_]init` functions to the
> pin-init API. These functions operate on already allocated smart
> pointers that contain `MaybeUninit<T>`.
>
> Signed-off-by: Benno Lossin <benno.lossin@proton.me>
> Link: https://lore.kernel.org/rust-for-linux/f026532f-8594-4f18-9aa5-57ad3f5bc592@proton.me/ [1]


I don't find the re_init name very intuitive. From the name I would
imagine these functions be taking a `Box<T>` and a `impl Init<T, E>`,
dropping the content and produces a `Box<T>` again.

Would it make more to rename the existing functions to have `new` in
their name to indiciate that they allocate, e.g. `pin_new`, and have
these functions that only does initialisation `init`/`pin_init`?

Best,
Gary

\
 
 \ /
  Last update: 2024-04-29 14:25    [W:0.088 / U:0.412 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site