Self-by-value builders returning ownership of the builder after an error #82
dtolnay
started this conversation in
API Guidelines
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The user may not be able to tell ahead of time whether the arguments passed to
f
will result in an error. They may want to handle the error but continue to use the same builder as thoughf
had 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_bytes
that 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.
Beta Was this translation helpful? Give feedback.
All reactions