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

Add assert_impl_one! macro #23

Merged
merged 2 commits into from
Oct 18, 2019
Merged

Add assert_impl_one! macro #23

merged 2 commits into from
Oct 18, 2019

Conversation

nvzqz
Copy link
Owner

@nvzqz nvzqz commented Oct 17, 2019

This adds assert_impl_one!, which ensures that exactly one in a set of traits is implemented.


This current implementation doesn't entirely work because traits after the first aren't checked against each other with assert_not_impl_all!.

Thanks to @SimonSapin's elegant solution, this macro is made possible. Subsequent traits were previously only checked against the first and not to one another. A correct implementation requires checking assert_not_impl_all! against all trait pairs. Also, it turns out that the "Mutually Exclusive Trait Implementations" docs before also wasn't implemented correctly for this reason.

nvzqz added 2 commits October 17, 2019 16:22
The current implementation doesn't entirely work because traits after
the first aren't checked against each other with `assert_not_impl_all!`.
Fixes the issue where subsequent traits were only checked against the
first trait and not to one another. This solution was made possible by
@SimonSapin demonstrating to me how to expand the input sequence into
combinations of inputs.

Closes #20.
@nvzqz nvzqz merged commit 8ebb869 into master Oct 18, 2019
@nvzqz nvzqz deleted the assert_impl_one branch October 18, 2019 17:50
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.

1 participant