Allow multiple bitflags structs in one macro invocation by konsumlamm · Pull Request #235 · bitflags/bitflags · GitHub
Skip to content

Allow multiple bitflags structs in one macro invocation - #235

Merged
KodrAus merged 2 commits into
bitflags:masterfrom
konsumlamm:multiple-bitflags
May 11, 2021
Merged

KodrAus merged 2 commits into
bitflags:masterfrom
konsumlamm:multiple-bitflags

Conversation

@konsumlamm

Copy link
Copy Markdown
Contributor

Add support for multiple bitflags structs in one macro invocation, for example:

bitflags! {
    pub struct Flags1: u32 {
        const A = 0b00000001;
    }

    struct Flags2: u32 {
        const B = 0b00000010;
    }
}

I also updated the documentation, replaced mentions of the flags keyword (which was used before 0.9) with struct and ran cargo fmt.

Change mentions of the `flags` keyword (used before 0.9) to `struct`
@KodrAus

KodrAus commented Jan 8, 2021

Copy link
Copy Markdown
Member

@konsumlamm

Copy link
Copy Markdown
Contributor Author

I can't quite spot from the diff, do we still have any tests that create a single flags type? That seems like a case worth keeping.

Yes, there are still plenty tests that only create a single flags type, for example in line 1379 or line 1444 and the tests in test_suite all still use single flags types. It may be worth to add a test for the empty case (bitflags! {}), but that's just one line and there's not much there that could go wrong.

@konsumlamm

Copy link
Copy Markdown
Contributor Author

@KodrAus ?

@KodrAus

KodrAus commented May 11, 2021

Copy link
Copy Markdown
Member

@KodrAus
KodrAus merged commit bd24f9d into bitflags:master May 11, 2021
@konsumlamm
konsumlamm deleted the multiple-bitflags branch May 11, 2021 09:50
@KodrAus KodrAus mentioned this pull request Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants