Add ability to rename flags. #470
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#470
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?
Various functions allow interacting with the names of flags as strings (
Flag::name,parser, etc). However, these currently must work with theSCREAMING_SNAKE_CASEname of the flag as it appears in the source code, which is not always desirable.In Arti, we use bitflags for our router status flags, which have specific names assigned to them that do not match the Rust identifiers. It would be convenient to have a way of renaming flags with a attribute macro — here's where this usecase came up.
Thanks for the suggestion @WesleyAC 👍 I'm generally against adding custom attributes to the
bitflagsmacros because themacro_rulesmacros are already mostly busting at the seams.In this case though, I think it would be reasonable to support through an attribute since there's no other way around the issue. We would basically need to find any places we call
stringify!and replace them with another macro call that also accepted the attributes on the flag and figured out what its actual name should be.