hawkw / mycelium

🍄 an alleged 'operating system'
https://mycelium.elizas.website
MIT License
537 stars 19 forks source link

refac: use `enum_from_bits!` where appropriate #452

Closed hawkw closed 1 year ago

hawkw commented 1 year ago

Depends on #450.

This branch replaces some boilerplate implementations of FromBits for enum types with the enum_from_bits! macro added to mycelium-bitfield in #450.

I didn't touch a couple manual FromBits implementations. Some parts of mycelium-pci manually implement FromBits in order to return a custom error type, so I left those alone. A few places in maitake use manual implementations for enums that cover all possible 2-bit bit patterns, so that the error arm can be unreachable_unchecked!. I didn't touch those either, since the perf delta may actually matter in those cases.