NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io · #802 most downloaded on crates.io
Enum-based bit flags
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
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%.One column per quarter.
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.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
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
Your coding agent can read these notes before it upgrades. Set up the MCP server →