Skip to content
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

The build function in Builder derive macro should take ownership #70

Open
dupeiran001 opened this issue Feb 26, 2024 · 1 comment
Open

Comments

@dupeiran001
Copy link

In the build derive macro, 04-call-builder, the build function takes a &mut self, and it returns a Command with the ownership of the fields. So I have to clone the fields in the implementation, which is not correct I suppose.

The build function should take the ownership of Builder, and return a builded result.

like this:

fn build(self) -> Result<Command, dyn Error>{
    unimplemented!()
}
@shouya
Copy link

shouya commented Apr 28, 2024

So I have to clone the fields in the implementation

To avoid cloning, you can look into Option::take as well as Vec::split_off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants