Skip to content

Conversation

BennoLossin
Copy link
Member

  • add code blocks to [try_][pin_]init! macros

@BennoLossin
Copy link
Member Author

@Darksonn in your proposal you said that only super let bindings would persist between different {} scopes in intializers. At the moment, this implements that behavior for normal let bindings. Any thoughts on that?

@BennoLossin BennoLossin changed the title Dev/underscore add initializer code blocks Aug 11, 2025
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`");
        },
    })

Signed-off-by: Benno Lossin <[email protected]>
Signed-off-by: Benno Lossin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant