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

refactor: make some options non-exhaustive #27

Merged
merged 1 commit into from
Jan 25, 2024

Conversation

ctron
Copy link
Owner

@ctron ctron commented Jan 24, 2024

BREAKING-CHANGE: In order to allow adding new options in the future,
the structs LoginOptions and LogoutOptions have been made
non-exhaustive. Adding some documentation on how to work with them.

@kate-shine @AlexandreRoba @DerKnerd It would be great if you could give this a quick look. I think this should simplify adding new fields in the future. But it will break the API right now. Which the two pending PRs seem to do anyway. That's fine, but let's take the opportunity to improve this.

Copy link
Contributor

@kate-shine kate-shine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this will make everything way nicer going forward :)

src/agent/mod.rs Outdated
/// # let url = Url::parse("https://example.com").unwrap();
/// let opts = LoginOptions {
/// redirect_url: Some(url),
/// ..Default::default()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional update syntax doesn't work with non_exhaustive structs, so this won't work (And I'd say it makes constructing options a bit awkward anyway, builder pattern is way nicer).

At this point, I think that giving those fields pub(crate) visibility and thus enforcing builder pattern would lead to less confusing backwards compatible api :)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, just figured that out …

At this point, I think that giving those fields pub(crate) visibility and thus enforcing builder pattern would lead to less confusing backwards compatible api :)

Good point!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am with @kate-shine the builder pattern would be way easier to extend and make it easier to use too.

@ctron ctron force-pushed the feature/non_exhaustive_options_1 branch from 0a66625 to b794f6e Compare January 24, 2024 08:06
BREAKING-CHANGE: In order to allow adding new options in the future,
 the structs LoginOptions and LogoutOptions have been made
 non-exhaustive. Adding some documentation on how to work with them.
@ctron ctron force-pushed the feature/non_exhaustive_options_1 branch from b794f6e to 2217ce0 Compare January 24, 2024 08:09
@ctron ctron merged commit 066e0d7 into main Jan 25, 2024
3 checks passed
@ctron ctron deleted the feature/non_exhaustive_options_1 branch January 25, 2024 08:09
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.

3 participants