Replace manual bit flags with auto-generated bit flag construct
Created by: huntergoldstein
Problem: There are small ergonomics issues with using hand-rolled bit flags as described in #308 (closed).
Solution: Replace the use of the hand-rolled flags with auto-generated bitflags
structures that provide nice mnemonics for membership while being mostly compatible with the old syntax.
Changes introduced by this pull request:
- Bitflags have been replaced with
bitflag!
equivalents as per the bitflag crate
Drawbacks:
- I'm not entirely sure if this is any more readable than before: part of the problem is
contains
versusintersects
, wherefoo.contains(bar)
isfoo & bar == bar
andfoo.intersects(bar)
isfoo & bar != 0
. These names are non-intuitive. - In addition to the above, the operators tended to be much more concise so for the most part I tried to not replace them with the mnemonics.
- There is a slight chance that this is overall less efficient (more function calls) but I highly doubt it; the
bitflags
crate essentially has#[inline]
on every function
Fixes: Closes #308 (closed).
State: I'm on the fence on whether or not this is a worthwhile addition, but I have nothing else to add.