-
Notifications
You must be signed in to change notification settings - Fork 52
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
Calling some methods on the builder type directly without calling .build()
#124
Comments
buildstructor might work for you?
struct MyStruct {
foo: usize,
bar: usize,
}
#[buildstructor::buildstructor]
impl MyStruct {
#[builder(exit = "run")]
async fn new(foo: usize, bar: usize) -> bool {
(Self { foo, bar }).run()
}
fn run(self) -> bool {
self.foo == self.bar
}
}
#[tokio::main]
async fn main() {
let result = MyStruct::builder().foo(4).bar(2).run().await;
assert_eq!(result, false);
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I use the builder pattern mainly to emulate named arguments. But I don't want to have to call
build
.What I must do currently
What I hope for
The text was updated successfully, but these errors were encountered: