Want builder-consuming build methods
@nick writes in !474 (comment 2800482)
Incidentally this
clone
makes me with that derive_builder also created a "consuming build" method, for cases where we can destroy the builder and move its members into the build object.
I agree. I think options are:
- Have derive_builder provide
build_consuming
alongsidebuild
. (I think.build()
would be.clone().build_consuming()
internally.) Name TBD. - Change our
build
to consume and ask people who want that to do.clone().build()
. This would breakBlahBuilder::default().some_param(42).build()
because thesome_param
setter returns only a borrow of the builder.
I considered the following but ruled them out:
- Change our use of derive_builder to request the "owned" pattern (doesn't work with sub-builders, since the sub-builder accessor must return
&mut
) - Do something different for different structs (the inconsistency would be pretty awful).
I'm quite a fan of 2, actually. But it would be an API break.