enumflags2
Enum-based bit flags
0.7.12
100M downloads/mo
#806 most downloaded on crates.io
meithecatte/enumflags2
What this package is like to depend on
Last release 1 years ago
09 Jun 2025
Release timing varies
gaps range from 2 weeks to 12 months
Some releases are documented
notes for 4 of 14 stable releases
7 versions withdrawn
withdrawn after publishing
8 years old
22 releases · first in 2019
0 releases in the last 12 months
see the full history below
Release timeline
22 releases · Jan 2019 to Jun 2025Releases
latest 22-
0.7.1209 Jun 2025Nothing published for this version
-
0.7.1117 Jan 2025Nothing published for this version
-
0.7.1007 Jun 2024Release notes
Open source →- Fix a case where the
#[bitflags]macro would access the crate throughenumflags2::...instead of::enumflags2::.... This makes the generated code more robust and avoids triggering theunused_qualificationslint. (#58) - Rework the proc-macro to use
synwith thederivefeature (as opposed tofull). This reduces thecargo buildtime forenumflags2by about 20%.
- Fix a case where the
-
0.7.912 Feb 2024Release notes
Open source →- The
BitFlagtrait now includes convenience re-exports for the constructors ofBitFlags. This lets you doMyFlag::from_bitsinsteadBitFlags::<MyFlag>::from_bitswhere the type of the flag cannot be inferred from context (thanks @ronnodas). - The documentation now calls out the fact that the implementation of
PartialOrdmay not be what you expect (reported by @ronnodas).
- The
-
0.7.813 Sep 2023Release notes
Open source →- New API:
BitFlags::set. Sets the value of a specific flag to that of theboolpassed as argument. (thanks, @m4dh0rs3) BitFlagsnow implementsPartialOrdandOrd, to make it possible to use it as a key in aBTreeMap.- The bounds on the implementation of
Hashgot improved, so that it is possible to use it in code generic overT: BitFlag.
- New API:
-
0.7.717 Apr 2023Release notes
Open source →This release fixes a soundness issue in the
make_bitflags!macro. Previously, code like this was accepted:#[bitflags] #[repr(u8)] #[derive(Copy, Clone, Debug)] enum Test { A = 1, B = 2, } impl Test { const C: u8 = 69; } fn main() { let x = make_bitflags!(Test::{C}); }
Iterating over
xwould then create values ofTestwith bit patterns that don't correspond to any of the variants, which is undefined behavior.This bug has been introduced in 0.7.0, together with the
make_bitflags!macro itself.I don't think it is likely that this was actually present in anyone's code, but in an abundance of caution, I have yanked all affected versions.
This issue has been assigned RUSTSEC-2023-0035.
-
0.7.601 Apr 2023 withdrawnRelease notes
Open source →- Update to
syn2.0 (thanks to @mwkmwkmwk) - Bump MSRV to 1.56.0 to support the above
- Update crate metadata to compensate for gender drift :3
- Update to
-
0.7.510 Apr 2022 withdrawnRelease notes
Open source →BitFlagsnow implementsDisplay, which only shows the flag list (without the binary representation). -
0.7.424 Mar 2022 withdrawnRelease notes
Open source →- Added
BitFlags::len, which returns the number of flags set. - Added
BitFlags::exactly_one, which converts a singleton flag set to the flag. ReturnsOption::Noneif the input is not a singleton. - The iterator returned by
BitFlags::iternow implementsExactSizeIteratorandFusedIterator. BitFlagsnow implementsIntoIterator.
- Added
-
0.7.326 Dec 2021 withdrawnRelease notes
Open source →- The code generated by the macro no longer triggers Clippy's
use_selflint. To prevent further issues of this kind, Clippy now runs on the test suite in CI, with the pedantic and nursery lints enabled too. - Some more functions are marked
#[inline]now. This will probably improve downstream performance in non-LTO builds. - Some more functions are marked
#[must_use]now, at the suggestion of Clippy. If this triggers, your code was probably weird and/or broken, but it's not really a mistake I'd expect anyone to make. - Minor documentation improvements.
- The code generated by the macro no longer triggers Clippy's
-
0.7.214 Dec 2021 withdrawnNothing published for this version
-
0.7.124 Feb 2021 withdrawnNothing published for this version
-
0.7.024 Feb 2021 withdrawnNothing published for this version
-
0.7.0-preview112 Aug 2020 pre-releaseNothing published for this version
-
0.6.421 Apr 2020Nothing published for this version
-
0.6.311 Apr 2020Nothing published for this version
-
0.6.216 Nov 2019Nothing published for this version
-
0.6.124 Oct 2019Nothing published for this version
-
0.6.004 Oct 2019Nothing published for this version
-
0.5.202 May 2019Nothing published for this version
-
0.5.102 Apr 2019Nothing published for this version
-
0.5.029 Jan 2019Nothing published for this version