Re: [PATCH] rust: pin-init: add code blocks to `[try_][pin_]init!` macros
From: Benno Lossin
Date: Thu Sep 11 2025 - 17:35:05 EST
On Fri Sep 5, 2025 at 4:05 PM CEST, Benno Lossin wrote:
> Allow writing `_: { /* any number of statements */ }` in initializers to
> run arbitrary code during initialization.
>
> try_init!(MyStruct {
> _: {
> if check_something() {
> return Err(MyError);
> }
> },
> foo: Foo::new(val),
> _: {
> println!("successfully initialized `MyStruct`");
> },
> })
>
> Link: https://github.com/Rust-for-Linux/pin-init/pull/84/commits/2880a9b898336e2d54f80715f00ce00f21f74d2f
> Signed-off-by: Benno Lossin <lossin@xxxxxxxxxx>
Applied to pin-init-next, thanks everyone!
---
Cheers,
Benno