Use compile-time checked infallible builders #395
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #372. The diff is big because basically all tests use builders, so I had to do a lot of boilerplate changes to the builder syntax. Examples of changes:
I also changed the
all_*()
methods to be part of the type itself instead of the builder struct, because they just return the type itself directly, and now that builders are ment to be created withT::builder()
it's easier to callT::all_*
whenT
is already imported into scope.Also builders moved from by-reference to by-value
self
, becausebon
generates a type-state-based builder that changes its type on every setter call.For some methods like
TBuilder::all(&mut Self)
I had to do a changeall(self) -> Self)
and that this method can be only called at the beginning of the builder method call chain. For exampleT::builder().all().foo().build()
works, while this doesn't compile:T::builder().foo().all().build()
, because.all()
is only available at the start.