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

Use compile-time checked infallible builders #395

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Veetaha
Copy link

@Veetaha Veetaha commented Jan 9, 2025

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:

GitBuilder::deault().build()?;
// vvv
Git::builder().build();

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 with T::builder() it's easier to call T::all_* when T is already imported into scope.

GitBuilder::all_git();
// vvv
Git::all_git();

Also builders moved from by-reference to by-value self, because bon 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 change all(self) -> Self) and that this method can be only called at the beginning of the builder method call chain. For example T::builder().all().foo().build() works, while this doesn't compile: T::builder().foo().all().build(), because .all() is only available at the start.

@Veetaha Veetaha changed the title Initial commit Use compile-time checked infallible builders Jan 9, 2025
@Veetaha Veetaha marked this pull request as draft January 9, 2025 02:41
@Veetaha Veetaha marked this pull request as ready for review January 9, 2025 18:38
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

Successfully merging this pull request may close these issues.

Consider making the builders infallible
1 participant