-
Notifications
You must be signed in to change notification settings - Fork 15
add [pin_]init_scope
to execute code before creating an initializer
#86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
91f324f
to
7f2ed79
Compare
7f2ed79
to
a90f441
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Feel free to add my Reviewed-by when sending to the list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the comments addressed:
Reviewed-by: Danilo Krummrich [email protected]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the comments addressed:
Reviewed-by: Danilo Krummrich [email protected]
In more complex cases, initializers need to run arbitrary code before assigning initializers to fields. While this is possible using the underscore codeblock feature (`_: {}`), values returned by such functions cannot be used from later field initializers. The two new functinos `[pin_]init_scope` allow users to first run some fallible code and then return an initializer which the function turns into a single initializer. This permits using the same value multiple times by different fields. Reviewed-by: Gary Guo <[email protected]> Reviewed-by: Danilo Krummrich [email protected] Signed-off-by: Benno Lossin <[email protected]>
a90f441
to
9e493c9
Compare
No description provided.