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 a hidden trait to discourage manual impls of BitFlags #261

Merged
merged 7 commits into from Oct 26, 2021

Conversation

KodrAus
Copy link
Member

@KodrAus KodrAus commented Oct 23, 2021

Followup to #220

cc @konsumlamm @arturoc

This adds a hidden supertrait to our new BitFlags trait that suggests you shouldn't implement it manually. Since we only support BitFlags through the bitflags! macro it means we could safely add new methods and supertraits (like Add and friends) to BitFlags without breaking consumers.

I've also just been adding to our test suite wherever I can too so there are some other new tests added there too.

@arturoc
Copy link

arturoc commented Oct 23, 2021

That makes a lot of sense yeah.

src/bitflags_trait.rs Outdated Show resolved Hide resolved
src/bitflags_trait.rs Outdated Show resolved Hide resolved
KodrAus and others added 4 commits October 25, 2021 09:04
Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
@KodrAus
Copy link
Member Author

KodrAus commented Oct 25, 2021

Thanks @konsumlamm and @arturoc! This should be ready for another look now.

@konsumlamm
Copy link
Contributor

I expected this to be an error after #261 (comment), but it still compiles (because of the extern crate core as _core in lib.rs). Nevertheless, this should just return Option<Self>:

https://github.com/KodrAus/bitflags/blob/b924d4c6487041ae491b860b6b8e21739e9602c5/src/bitflags_trait.rs#L17

@KodrAus
Copy link
Member Author

KodrAus commented Oct 26, 2021

Alrighty, I’ll merge this one in and we can follow up with some more bits and pieces. Thanks!

@KodrAus KodrAus merged commit 1aa25e1 into bitflags:main Oct 26, 2021
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.

None yet

3 participants