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 upSelf-by-value builders returning ownership of the builder after an error #82
Comments
dtolnay
referenced this issue
May 31, 2017
Open
Strengthen the recommendation to use &mut self builders #81
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
The user may not be able to tell ahead of time whether the arguments passed to
fwill result in an error. They may want to handle the error but continue to use the same builder as thoughfhad not been called, which is typically possible with a &mut self builder.Thus it can be a good idea for the error type to provide access to the builder that failed. This is similar to the idea behind
FromUtf8Error::into_bytesthat returns ownership of the bytes that failed UTF-8 conversion.Need to be careful with Send and Sync though. Error types are expected to be Send and Sync but the builder may not be, so it may not be possible to stash the builder inside of the error type.