Releases: meithecatte/enumflags2
Releases · meithecatte/enumflags2
Release 0.7.10
- 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%.
Release 0.7.9
- 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).
Release 0.7.8
- 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.
Release 0.7.7
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.
Release 0.7.6
- 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
Release 0.7.5
BitFlags now implements Display, which only shows the flag list (without the binary representation).
Release 0.7.4
- 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.
Release 0.7.3
- 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.
Release 0.7.2
The iterator returned by BitFlags::iter now implements Clone.
Release 0.7.0
Release 0.7.0
- Breaking change: instead of
#[derive(BitFlags)], the macro is now#[bitflags]- This allows a long-awaited feature: when a discriminant isn't provided, the macro will choose an unused bit for you.
- You can now create instances of
BitFlagswithout repeating the name:make_bitflags!(MyFlags::{Foo, Bar})instead ofMyFlags::Foo | MyFlags::Bar. Works in aconst fn, too! - Many new APIs that allow working with
BitFlagsin aconst fndespite rustc limitations - Many improved error messages
- Implementation details do not show up in user documentation anymore
- Breaking change: rename the
RawBitFlagstrait toBitFlag- there's nothing raw about it - Breaking change: the
not_literalfeature doesn't exist, the relevant functionality is now enabled by default - there is no concern about confusing error messages anymore - Breaking change: the
#[repr(u??)]attribute is now required - previously, Rust's default ofusizewas used, which is a terrible idea for the size of a bitfield - Breaking change:
BitFlags::newis now calledfrom_bits_unchecked-newsuggests that this is the main, preferred way of creatingBitFlags. This is not the case. - the value returned by
Default::defaultcan now be customized with#[bitflags(default = Foo | Bar)]