Re: [PATCH] rust: pin-init: add references to previously initialized fields
From: Danilo Krummrich
Date: Sun Sep 07 2025 - 19:33:31 EST
On Mon Sep 8, 2025 at 12:51 AM CEST, Benno Lossin wrote:
> I actually came up with a third option that looks best IMO:
>
> init!(MyStruct {
> x: 42,
> #[with_binding]
> y: 24,
> z: *y,
> })
>
> The `#[with_binding]` attribute makes the macro generate a variable `y`.
> `x` & `z` don't give access to their value. (we of course should come up
> with a better name).
>
> Any thoughts?
It may be a bit verbose is some cases, but it makes things pretty obvious, so
LGTM.
How about just #[bind] or #[access]?