Split bitflags macro and traits into 2.5 macros/traits #419
Labels
No labels
bug
good first issue
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-bitflags/bitflags#419
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This issue tries to outline a solution to some of the problems of bitflags. There is plenty room for discussion right now.
bitflag suffers from the fact that it hadn't a defined target group for a long time and got request from different directions with different requirements. This improved over the last releases and we now have largely consistent behaviour and a definition of the status quo. However this is still a compromise that does neither bring the one side full feature power nor the other.
The overall idea is to have more than one bitflags type (type here means macro/trait = API).
FFIFlagsWeak/FFIFlagsStrictOne major use of
bitflagsis for type-safe ffi types commonly found on C APIs.#[repr(C)].RustFlagsThe second use are sane, type-safe, well-defined, comfortable Rust-to-Rust APIs.
#[repr(Rust)].autoflags.struct { bool, bool, bool, bool, bool, bool, bool, bool }The tension between these has definitely caused us trouble in the past, and we've largely started catering to the former group more than the latter these days. For the latter group, I've thought a proc-macro library that was fully strict might be a good fit. There are a few out there already, such as this one, but I'm not sure how far they go to deal with the oddities around multi-bit flags, which I think should be disallowed, like your example of basically producing a struct of bools.
I think there's definitely room for a library that took the approach of if flags types were going to be a language feature in Rust, how would they work? and would love to see it get built.