Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upBuilders that take &mut self should panic when used a second time #83
Comments
This comment has been minimized.
This comment has been minimized.
Kixunil
commented
May 31, 2017
|
Why not just consume builder instead? Compile-time checking FTW. |
This comment has been minimized.
This comment has been minimized.
|
Because then you can't write |
This comment has been minimized.
This comment has been minimized.
Kixunil
commented
May 31, 2017
|
Ah, I see. In that case I'd say consume everything. |
dtolnay
added
the
clarification
label
Sep 18, 2017
dtolnay
added
the
hacktoberfest
label
Oct 1, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dtolnay commentedMay 31, 2017
If you want to support this behavior, provide Clone for the builder.
In general, the user should not be allowed to rely on a builder being in any particular state after calling the terminal method (
buildor similar). If the ergonomics of doing so weren't awful, the terminal method would take self by value instead of &mut self.