Re: [RFC PATCH 1/2] rust: list: Implement normal initializer for ListLinks

From: Alice Ryhl
Date: Mon Mar 10 2025 - 05:46:39 EST


On Mon, Mar 10, 2025 at 03:30:39PM +0800, I Hsin Cheng wrote:
> Currently ListLinks only supports to create an initializer through
> "new()", which will need further initialization because the return type
> of "new()" is "impl Pininit<Self>". Not even "ListLinksSlefPtr" use the
> method to create a new instance of "ListLinks".
>
> Implement a normal method to create a new instance of type "ListLinks".
> This may be redundant as long as there exist a convenient and proper way
> to deal with "ListLinks::new()".
>
> For now it's introduce for the simplicity of examples in the following
> patches.
>
> Signed-off-by: I Hsin Cheng <richard120310@xxxxxxxxx>

This change is not good. The ListLinks type has an invariant about when
the pointers are null. The existing constructor argues that the
invariant is satisfied because pin-init initializers can't be used in an
existing Arc. Why is that satisfied here?

Alice