Skip to content

Modernization and default generation#205

Closed
npmccallum wants to merge 7 commits intobitflags:mainfrom
npmccallum:master
Closed

Modernization and default generation#205
npmccallum wants to merge 7 commits intobitflags:mainfrom
npmccallum:master

Conversation

@npmccallum
Copy link

This PR contains five patches. Four do modernization work. One implements a new default() suffix feature.

I pursued modernization first because it simplified the macro structure before adding a new macro feature.

My main interest is the default() suffix feature. The existing methods for doing impl Default have served us fairly well. However, their main drawback is that we don't have the opportunity to generate a const fn default() for use in constant contexts.

This bumps the minimum required Rust version to 1.30.
This bumps the minimum required Rust version to 1.31.
This commit enables the bitflag!() macro to receive a default() stuffix
which specifies which flags are included in the default. It generates both
an impl of the Default trait as well as a const fn default for use in
constant contexts.

This bumps the minimum required Rust version to 1.33.
Prefer "use bitflags::bitflags;" to "#[macro_use] extern crate bitflags;".
Modern rust doesn't require "extern crate foo;", therefore we can simplify
a number of things.
@KodrAus
Copy link
Member

KodrAus commented Jan 28, 2020

Thanks for the PR @npmccallum!

I think we should consider the modernization effort independently of the new default suffix feature. For the modernization we should be careful not to regress any existing callers.

For the default suffix feature we should spend some time exploring the design space and see what approaches we could take. Let's open up a separate issue for that.

@konsumlamm
Copy link
Contributor

@npmccallum do you plan to continue working on this? If not, I'd try to extract the modernization part and open a new PR for that.

@npmccallum
Copy link
Author

@konsumlamm go ahead!

@KodrAus
Copy link
Member

KodrAus commented Oct 23, 2021

Thanks for working on this @npmccallum! Things have steadily moved forwards here and your modernization changes have made their way through.

I'll go ahead and close this one for now. As for const Default, this is something we should be able to overcome soon when rust-lang/rust#71971 lands, allowing a impl const Default for Flags.

@KodrAus KodrAus closed this Oct 23, 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.

3 participants