-
Notifications
You must be signed in to change notification settings - Fork 8
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
Support using BuildPlanBuilder
without chaining
#295
Comments
To support the non-chained form, we'd need to
After that, the example without the additional assignment in the OP will work. In addition, the fully-chained form will still work, eg: let build_plan = BuildPlanBuilder::new().provides("python").build(); However this form will no longer work: let build_plan_builder = BuildPlanBuilder::new().provides("python");
let build_plan = build_plan_builder.build(); ...since it will give an error like:
Instead that would have to be switched to either the fully chained form, or else just make sure the return value from let build_plan_builder = BuildPlanBuilder::new();
let build_plan = build_plan_builder.provides("python").build(); To me, this seems fine, and so I'm leaning towards making this change. |
I really like the chained form and would hate to lose it, but I also had this issue recently. For more complex modification, what about a mutation function to avoid the mutable reassignment?
Where
|
Currently the methods on
BuildPlanBuilder
consumeself
since they takemut self
as the first method argument, eg:https://github.com/Malax/libcnb.rs/blob/39cb9879707e16323e44ff5e14408ba43d2b126c/libcnb-data/src/build_plan.rs#L48-L51
This means one cannot write something like:
And instead a reassignment has to be performed inside the conditional:
Unless there is a more idiomatic way to write the above, that I'm missing?
Contrast this to
ProcessBuilder
, which doesn't consumeself
:https://github.com/Malax/libcnb.rs/blob/5ffcd9c5ed2c9c95fa73e00930f693f13888ee33/libcnb-data/src/launch.rs#L132
In general we have quite a lot inconsistency between our builder types - cross-ref #166.
The text was updated successfully, but these errors were encountered: