refactor: replace bitflags with the expanded implementation
#590
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.
Ref #512
bitflagswas only being used forFontStyle, so it seems reasonable to me to just replace it with its expanded code (courtesy ofcargo-expandplus lots of manual cleanup). No more outdated dependency for anyone to complain about now 😆🙊. This also gives us the liberty of customizing the docs to our specific use along with being able to freely#[deprecate]anything that we want to drop with the next major release (I'm looking at youunsafe fn from_bits_unchecked(bits: u8) -> Self👀)That being said the generated code was very gross because it handled a bunch of edge-cases that we can ignore, so I also took a few passes at cleaning things up with -- what should be -- equivalent implementations. Take the original expanded debug impl for example (yes it was the worst of the bunch)
Cursed looking? Absolutely
Here's the cleaned up version
Unreachable branches like
if Self::BOLD.bits == 0 && self.bits != 0 {were pruned (none of our flags== 0). The internal__BitFlagstrait was removed entirely (including the default methods that were all unused). Etc. etc.Note: I took the liberty of removing all of the
#[inline]s because it's generally an optimization code smell to have on everything (and it was on virtually everything)