NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io
crates.io, #786 most downloaded on crates.io
Enum-based bit flags
Latest stable
0.7.12
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 6 of 14 stable releases
7 versions withdrawn
withdrawn after publishing
8 years old
22 releases · first in 2019
Drag across the ruler to compare, or tap a release to open it.
Nothing published for this version
Nothing published for this version
Fix a case where the #[bitflags] macro would access the crate through enumflags2::... instead of ::enumflags2::... . This makes the generated code mor
#[bitflags] macro would access the crate through enumflags2::... instead of ::enumflags2::.... This makes the generated code more robust and avoids triggering the unused_qualifications lint. (#58)syn with the derive feature (as opposed to full). This reduces the cargo build time for enumflags2 by about 20%.Your coding agent can read these notes before it upgrades. Set up the MCP server →
The BitFlag trait now includes convenience re-exports for the constructors of BitFlags . This lets you do MyFlag::from_bits instead BitFlags::<MyFlag>
BitFlag trait now includes convenience re-exports for the constructors of BitFlags. This lets you do MyFlag::from_bits instead BitFlags::<MyFlag>::from_bits where the type of the flag cannot be inferred from context (thanks @ronnodas).PartialOrd may not be what you expect (reported by @ronnodas).New API: BitFlags::set . Sets the value of a specific flag to that of the bool passed as argument. (thanks, @m4dh0rs3 )
BitFlags::set. Sets the value of a specific flag to that of the bool passed as argument. (thanks, @m4dh0rs3)BitFlags now implements PartialOrd and Ord, to make it possible to use it as a key in a BTreeMap.Hash got improved, so that it is possible to use it in code generic over T: BitFlag.This release fixes a soundness issue in the make_bitflags! macro. Previously, code like this was accepted:
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 x would then create values of Test with 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.
Update to syn 2.0 (thanks to @mwkmwkmwk )
syn 2.0 (thanks to @mwkmwkmwk)BitFlags now implements Display , which only shows the flag list (without the binary representation).
BitFlags now implements Display, which only shows the flag list (without the binary representation).
Added BitFlags::len , which returns the number of flags set.
BitFlags::len, which returns the number of flags set.BitFlags::exactly_one, which converts a singleton flag set to the flag. Returns Option::None if the input is not a singleton.BitFlags::iter now implements ExactSizeIterator and FusedIterator.BitFlags now implements IntoIterator.The code generated by the macro no longer triggers Clippy's use_self lint. To prevent further issues of this kind, Clippy now runs on the test suite i
use_self lint. To prevent further issues of this kind, Clippy now runs on the test suite in CI, with the pedantic and nursery lints enabled too.#[inline] now. This will probably improve downstream performance in non-LTO builds.#[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.The iterator returned by BitFlags::iter now implements Clone.
The iterator returned by BitFlags::iter now implements Clone.
Nothing published for this version
Breaking change: instead of #[derive(BitFlags)], the macro is now #[bitflags]
Release 0.7.0
#[derive(BitFlags)], the macro is now #[bitflags]
BitFlags without repeating the name: make_bitflags!(MyFlags::{Foo, Bar}) instead of MyFlags::Foo | MyFlags::Bar. Works in a const fn, too!BitFlags in a const fn despite rustc limitationsRawBitFlags trait to BitFlag - there's nothing raw about itnot_literal feature doesn't exist, the relevant functionality is now enabled by default - there is no concern about confusing error messages anymore#[repr(u??)] attribute is now required - previously, Rust's default of usize was used, which is a terrible idea for the size of a bitfieldBitFlags::new is now called from_bits_unchecked - new suggests that this is the main, preferred way of creating BitFlags. This is not the case.Default::default can now be customized with #[bitflags(default = Foo | Bar)]Nothing published for this version
implement Eq, Hash and Extend for BitFlags
Eq, Hash and Extend for BitFlagsFromIterator is now 15% faster in some use casesModify the generated code slightly to avoid triggerring the trivial_numeric_casts lint.
Modify the generated code slightly to avoid triggerring the trivial_numeric_casts lint.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.