1# 2.5.0 2 3## What's Changed 4* Derive `Debug` for `Flag<B>` by @tgross35 in https://github.com/bitflags/bitflags/pull/398 5* Support truncating or strict-named variants of parsing and formatting by @KodrAus in https://github.com/bitflags/bitflags/pull/400 6 7## New Contributors 8* @tgross35 made their first contribution in https://github.com/bitflags/bitflags/pull/398 9 10**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.4.2...2.5.0 11 12# 2.4.2 13 14## What's Changed 15* Cargo.toml: Anchor excludes to root of the package by @jamessan in https://github.com/bitflags/bitflags/pull/387 16* Update error messages by @KodrAus in https://github.com/bitflags/bitflags/pull/390 17* Add support for impl mode structs to be repr(packed) by @GnomedDev in https://github.com/bitflags/bitflags/pull/388 18* Remove old `unused_tuple_struct_fields` lint by @dtolnay in https://github.com/bitflags/bitflags/pull/393 19* Delete use of `local_inner_macros` by @dtolnay in https://github.com/bitflags/bitflags/pull/392 20 21## New Contributors 22* @jamessan made their first contribution in https://github.com/bitflags/bitflags/pull/387 23* @GnomedDev made their first contribution in https://github.com/bitflags/bitflags/pull/388 24 25**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.4.1...2.4.2 26 27# 2.4.1 28 29## What's Changed 30* Allow some new pedantic clippy lints by @KodrAus in https://github.com/bitflags/bitflags/pull/380 31 32**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.4.0...2.4.1 33 34# 2.4.0 35 36## What's Changed 37* Remove html_root_url by @eldruin in https://github.com/bitflags/bitflags/pull/368 38* Support unnamed flags by @KodrAus in https://github.com/bitflags/bitflags/pull/371 39* Update smoke test to verify all Clippy and rustc lints by @MitMaro in https://github.com/bitflags/bitflags/pull/374 40* Specify the behavior of bitflags by @KodrAus in https://github.com/bitflags/bitflags/pull/369 41 42## New Contributors 43* @eldruin made their first contribution in https://github.com/bitflags/bitflags/pull/368 44* @MitMaro made their first contribution in https://github.com/bitflags/bitflags/pull/374 45 46**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.3.3...2.4.0 47 48# 2.3.3 49 50## Changes to `-=` 51 52The `-=` operator was incorrectly changed to truncate bits that didn't correspond to valid flags in `2.3.0`. This has 53been fixed up so it once again behaves the same as `-` and `difference`. 54 55## Changes to `!` 56 57The `!` operator previously called `Self::from_bits_truncate`, which would truncate any bits that only partially 58overlapped with a valid flag. It will now use `bits & Self::all().bits()`, so any bits that overlap any bits 59specified by any flag will be respected. This is unlikely to have any practical implications, but enables defining 60a flag like `const ALL = !0` as a way to signal that any bit pattern is a known set of flags. 61 62## Changes to formatting 63 64Zero-valued flags will never be printed. You'll either get `0x0` for empty flags using debug formatting, or the 65set of flags with zero-valued flags omitted for others. 66 67Composite flags will no longer be redundantly printed if there are extra bits to print at the end that don't correspond 68to a valid flag. 69 70## What's Changed 71* Fix up incorrect sub assign behavior and other cleanups by @KodrAus in https://github.com/bitflags/bitflags/pull/366 72 73**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.3.2...2.3.3 74 75# 2.3.2 76 77## What's Changed 78* [doc] [src/lib.rs] delete redundant path prefix by @OccupyMars2025 in https://github.com/bitflags/bitflags/pull/361 79 80## New Contributors 81* @OccupyMars2025 made their first contribution in https://github.com/bitflags/bitflags/pull/361 82 83**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.3.1...2.3.2 84 85# 2.3.1 86 87## What's Changed 88* Fix Self in flags value expressions by @KodrAus in https://github.com/bitflags/bitflags/pull/355 89 90**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.3.0...2.3.1 91 92# 2.3.0 93 94## What's Changed 95* Support ejecting flags types from the bitflags macro by @KodrAus in https://github.com/bitflags/bitflags/pull/351 96 97**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.2.1...2.3.0 98 99# 2.2.1 100 101## What's Changed 102* Refactor attribute filtering to apply per-flag by @KodrAus in https://github.com/bitflags/bitflags/pull/345 103 104**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.2.0...2.2.1 105 106# 2.2.0 107 108## What's Changed 109* Create SECURITY.md by @KodrAus in https://github.com/bitflags/bitflags/pull/338 110* add docs to describe the behavior of multi-bit flags by @nicholasbishop in https://github.com/bitflags/bitflags/pull/340 111* Add support for bytemuck by @KodrAus in https://github.com/bitflags/bitflags/pull/336 112* Add a top-level macro for filtering attributes by @KodrAus in https://github.com/bitflags/bitflags/pull/341 113 114## New Contributors 115* @nicholasbishop made their first contribution in https://github.com/bitflags/bitflags/pull/340 116 117**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.1.0...2.2.0 118 119# 2.1.0 120 121## What's Changed 122* Add docs for the internal Field0 and examples of formatting/parsing by @KodrAus in https://github.com/bitflags/bitflags/pull/328 123* Add support for arbitrary by @KodrAus in https://github.com/bitflags/bitflags/pull/324 124* Fix up missing docs for consts within consts by @KodrAus in https://github.com/bitflags/bitflags/pull/330 125* Ignore clippy lint in generated code by @Jake-Shadle in https://github.com/bitflags/bitflags/pull/331 126 127## New Contributors 128* @Jake-Shadle made their first contribution in https://github.com/bitflags/bitflags/pull/331 129 130**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.0.2...2.1.0 131 132# 2.0.2 133 134## What's Changed 135* Fix up missing isize and usize Bits impls by @KodrAus in https://github.com/bitflags/bitflags/pull/321 136 137**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.0.1...2.0.2 138 139# 2.0.1 140 141## What's Changed 142* Fix up some docs issues by @KodrAus in https://github.com/bitflags/bitflags/pull/309 143* Make empty_flag() const. by @tormeh in https://github.com/bitflags/bitflags/pull/313 144* Fix formatting of multi-bit flags with partial overlap by @KodrAus in https://github.com/bitflags/bitflags/pull/316 145 146## New Contributors 147* @tormeh made their first contribution in https://github.com/bitflags/bitflags/pull/313 148 149**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.0.0...2.0.1 150 151# 2.0.0 152 153## What's Changed 154* Fix a typo and call out MSRV bump by @KodrAus in https://github.com/bitflags/bitflags/pull/259 155* BitFlags trait by @arturoc in https://github.com/bitflags/bitflags/pull/220 156* Add a hidden trait to discourage manual impls of BitFlags by @KodrAus in https://github.com/bitflags/bitflags/pull/261 157* Sanitize `Ok` by @konsumlamm in https://github.com/bitflags/bitflags/pull/266 158* Fix bug in `Debug` implementation by @konsumlamm in https://github.com/bitflags/bitflags/pull/268 159* Fix a typo in the generated documentation by @wackbyte in https://github.com/bitflags/bitflags/pull/271 160* Use SPDX license format by @atouchet in https://github.com/bitflags/bitflags/pull/272 161* serde tests fail in CI by @arturoc in https://github.com/bitflags/bitflags/pull/277 162* Fix beta test output by @KodrAus in https://github.com/bitflags/bitflags/pull/279 163* Add example to the README.md file by @tiaanl in https://github.com/bitflags/bitflags/pull/270 164* Iterator over all the enabled options by @arturoc in https://github.com/bitflags/bitflags/pull/278 165* from_bits_(truncate) fail with composite flags by @arturoc in https://github.com/bitflags/bitflags/pull/276 166* Add more platform coverage to CI by @KodrAus in https://github.com/bitflags/bitflags/pull/280 167* rework the way cfgs are handled by @KodrAus in https://github.com/bitflags/bitflags/pull/281 168* Split generated code into two types by @KodrAus in https://github.com/bitflags/bitflags/pull/282 169* expose bitflags iters using nameable types by @KodrAus in https://github.com/bitflags/bitflags/pull/286 170* Support creating flags from their names by @KodrAus in https://github.com/bitflags/bitflags/pull/287 171* Update README.md by @KodrAus in https://github.com/bitflags/bitflags/pull/288 172* Prepare for 2.0.0-rc.1 release by @KodrAus in https://github.com/bitflags/bitflags/pull/289 173* Add missing "if" to contains doc-comment in traits.rs by @rusty-snake in https://github.com/bitflags/bitflags/pull/291 174* Forbid unsafe_code by @fintelia in https://github.com/bitflags/bitflags/pull/294 175* serde: enable no-std support by @nim65s in https://github.com/bitflags/bitflags/pull/296 176* Add a parser for flags formatted as bar-separated-values by @KodrAus in https://github.com/bitflags/bitflags/pull/297 177* Prepare for 2.0.0-rc.2 release by @KodrAus in https://github.com/bitflags/bitflags/pull/299 178* Use strip_prefix instead of starts_with + slice by @QuinnPainter in https://github.com/bitflags/bitflags/pull/301 179* Fix up some clippy lints by @KodrAus in https://github.com/bitflags/bitflags/pull/302 180* Prepare for 2.0.0-rc.3 release by @KodrAus in https://github.com/bitflags/bitflags/pull/303 181* feat: Add minimum permissions to rust.yml workflow by @gabibguti in https://github.com/bitflags/bitflags/pull/305 182 183## New Contributors 184* @wackbyte made their first contribution in https://github.com/bitflags/bitflags/pull/271 185* @atouchet made their first contribution in https://github.com/bitflags/bitflags/pull/272 186* @tiaanl made their first contribution in https://github.com/bitflags/bitflags/pull/270 187* @rusty-snake made their first contribution in https://github.com/bitflags/bitflags/pull/291 188* @fintelia made their first contribution in https://github.com/bitflags/bitflags/pull/294 189* @nim65s made their first contribution in https://github.com/bitflags/bitflags/pull/296 190* @QuinnPainter made their first contribution in https://github.com/bitflags/bitflags/pull/301 191* @gabibguti made their first contribution in https://github.com/bitflags/bitflags/pull/305 192 193**Full Changelog**: https://github.com/bitflags/bitflags/compare/1.3.2...2.0.0 194 195# 2.0.0-rc.3 196 197## What's Changed 198* Use strip_prefix instead of starts_with + slice by @QuinnPainter in https://github.com/bitflags/bitflags/pull/301 199* Fix up some clippy lints by @KodrAus in https://github.com/bitflags/bitflags/pull/302 200 201## New Contributors 202* @QuinnPainter made their first contribution in https://github.com/bitflags/bitflags/pull/301 203 204**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.0.0-rc.2...2.0.0-rc.3 205 206# 2.0.0-rc.2 207 208## Changes to `serde` serialization 209 210**⚠️ NOTE ⚠️** This release changes the default serialization you'll get if you `#[derive(Serialize, Deserialize)]` 211on your generated flags types. It will now use a formatted string for human-readable formats and the underlying bits 212type for compact formats. 213 214To keep the old behavior, see the [`bitflags-serde-legacy`](https://github.com/KodrAus/bitflags-serde-legacy) library. 215 216## What's Changed 217 218* Add missing "if" to contains doc-comment in traits.rs by @rusty-snake in https://github.com/bitflags/bitflags/pull/291 219* Forbid unsafe_code by @fintelia in https://github.com/bitflags/bitflags/pull/294 220* serde: enable no-std support by @nim65s in https://github.com/bitflags/bitflags/pull/296 221* Add a parser for flags formatted as bar-separated-values by @KodrAus in https://github.com/bitflags/bitflags/pull/297 222 223## New Contributors 224* @rusty-snake made their first contribution in https://github.com/bitflags/bitflags/pull/291 225* @fintelia made their first contribution in https://github.com/bitflags/bitflags/pull/294 226* @nim65s made their first contribution in https://github.com/bitflags/bitflags/pull/296 227 228**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.0.0-rc.1...2.0.0-rc.2 229 230# 2.0.0-rc.1 231 232This is a big release including a few years worth of work on a new `BitFlags` trait, iteration, and better macro organization for future extensibility. 233 234## What's Changed 235* Fix a typo and call out MSRV bump by @KodrAus in https://github.com/bitflags/bitflags/pull/259 236* BitFlags trait by @arturoc in https://github.com/bitflags/bitflags/pull/220 237* Add a hidden trait to discourage manual impls of BitFlags by @KodrAus in https://github.com/bitflags/bitflags/pull/261 238* Sanitize `Ok` by @konsumlamm in https://github.com/bitflags/bitflags/pull/266 239* Fix bug in `Debug` implementation by @konsumlamm in https://github.com/bitflags/bitflags/pull/268 240* Fix a typo in the generated documentation by @wackbyte in https://github.com/bitflags/bitflags/pull/271 241* Use SPDX license format by @atouchet in https://github.com/bitflags/bitflags/pull/272 242* serde tests fail in CI by @arturoc in https://github.com/bitflags/bitflags/pull/277 243* Fix beta test output by @KodrAus in https://github.com/bitflags/bitflags/pull/279 244* Add example to the README.md file by @tiaanl in https://github.com/bitflags/bitflags/pull/270 245* Iterator over all the enabled options by @arturoc in https://github.com/bitflags/bitflags/pull/278 246* from_bits_(truncate) fail with composite flags by @arturoc in https://github.com/bitflags/bitflags/pull/276 247* Add more platform coverage to CI by @KodrAus in https://github.com/bitflags/bitflags/pull/280 248* rework the way cfgs are handled by @KodrAus in https://github.com/bitflags/bitflags/pull/281 249* Split generated code into two types by @KodrAus in https://github.com/bitflags/bitflags/pull/282 250* expose bitflags iters using nameable types by @KodrAus in https://github.com/bitflags/bitflags/pull/286 251* Support creating flags from their names by @KodrAus in https://github.com/bitflags/bitflags/pull/287 252* Update README.md by @KodrAus in https://github.com/bitflags/bitflags/pull/288 253 254## New Contributors 255* @wackbyte made their first contribution in https://github.com/bitflags/bitflags/pull/271 256* @atouchet made their first contribution in https://github.com/bitflags/bitflags/pull/272 257* @tiaanl made their first contribution in https://github.com/bitflags/bitflags/pull/270 258 259**Full Changelog**: https://github.com/bitflags/bitflags/compare/1.3.2...2.0.0-rc.1 260 261# 1.3.2 262 263- Allow `non_snake_case` in generated flags types ([#256]) 264 265[#256]: https://github.com/bitflags/bitflags/pull/256 266 267# 1.3.1 268 269- Revert unconditional `#[repr(transparent)]` ([#252]) 270 271[#252]: https://github.com/bitflags/bitflags/pull/252 272 273# 1.3.0 (yanked) 274 275**This release bumps the Minimum Supported Rust Version to `1.46.0`** 276 277- Add `#[repr(transparent)]` ([#187]) 278 279- End `empty` doc comment with full stop ([#202]) 280 281- Fix typo in crate root docs ([#206]) 282 283- Document from_bits_unchecked unsafety ([#207]) 284 285- Let `is_all` ignore extra bits ([#211]) 286 287- Allows empty flag definition ([#225]) 288 289- Making crate accessible from std ([#227]) 290 291- Make `from_bits` a const fn ([#229]) 292 293- Allow multiple bitflags structs in one macro invocation ([#235]) 294 295- Add named functions to perform set operations ([#244]) 296 297- Fix typos in method docs ([#245]) 298 299- Modernization of the `bitflags` macro to take advantage of newer features and 2018 idioms ([#246]) 300 301- Fix regression (in an unreleased feature) and simplify tests ([#247]) 302 303- Use `Self` and fix bug when overriding `stringify!` ([#249]) 304 305[#187]: https://github.com/bitflags/bitflags/pull/187 306[#202]: https://github.com/bitflags/bitflags/pull/202 307[#206]: https://github.com/bitflags/bitflags/pull/206 308[#207]: https://github.com/bitflags/bitflags/pull/207 309[#211]: https://github.com/bitflags/bitflags/pull/211 310[#225]: https://github.com/bitflags/bitflags/pull/225 311[#227]: https://github.com/bitflags/bitflags/pull/227 312[#229]: https://github.com/bitflags/bitflags/pull/229 313[#235]: https://github.com/bitflags/bitflags/pull/235 314[#244]: https://github.com/bitflags/bitflags/pull/244 315[#245]: https://github.com/bitflags/bitflags/pull/245 316[#246]: https://github.com/bitflags/bitflags/pull/246 317[#247]: https://github.com/bitflags/bitflags/pull/247 318[#249]: https://github.com/bitflags/bitflags/pull/249 319 320# 1.2.1 321 322- Remove extraneous `#[inline]` attributes ([#194]) 323 324[#194]: https://github.com/bitflags/bitflags/pull/194 325 326# 1.2.0 327 328- Fix typo: {Lower, Upper}Exp - {Lower, Upper}Hex ([#183]) 329 330- Add support for "unknown" bits ([#188]) 331 332[#183]: https://github.com/rust-lang-nursery/bitflags/pull/183 333[#188]: https://github.com/rust-lang-nursery/bitflags/pull/188 334 335# 1.1.0 336 337This is a re-release of `1.0.5`, which was yanked due to a bug in the RLS. 338 339# 1.0.5 340 341- Use compiletest_rs flags supported by stable toolchain ([#171]) 342 343- Put the user provided attributes first ([#173]) 344 345- Make bitflags methods `const` on newer compilers ([#175]) 346 347[#171]: https://github.com/rust-lang-nursery/bitflags/pull/171 348[#173]: https://github.com/rust-lang-nursery/bitflags/pull/173 349[#175]: https://github.com/rust-lang-nursery/bitflags/pull/175 350 351# 1.0.4 352 353- Support Rust 2018 style macro imports ([#165]) 354 355 ```rust 356 use bitflags::bitflags; 357 ``` 358 359[#165]: https://github.com/rust-lang-nursery/bitflags/pull/165 360 361# 1.0.3 362 363- Improve zero value flag handling and documentation ([#157]) 364 365[#157]: https://github.com/rust-lang-nursery/bitflags/pull/157 366 367# 1.0.2 368 369- 30% improvement in compile time of bitflags crate ([#156]) 370 371- Documentation improvements ([#153]) 372 373- Implementation cleanup ([#149]) 374 375[#156]: https://github.com/rust-lang-nursery/bitflags/pull/156 376[#153]: https://github.com/rust-lang-nursery/bitflags/pull/153 377[#149]: https://github.com/rust-lang-nursery/bitflags/pull/149 378 379# 1.0.1 380- Add support for `pub(restricted)` specifier on the bitflags struct ([#135]) 381- Optimize performance of `all()` when called from a separate crate ([#136]) 382 383[#135]: https://github.com/rust-lang-nursery/bitflags/pull/135 384[#136]: https://github.com/rust-lang-nursery/bitflags/pull/136 385 386# 1.0.0 387- **[breaking change]** Macro now generates [associated constants](https://doc.rust-lang.org/reference/items.html#associated-constants) ([#24]) 388 389- **[breaking change]** Minimum supported version is Rust **1.20**, due to usage of associated constants 390 391- After being broken in 0.9, the `#[deprecated]` attribute is now supported again ([#112]) 392 393- Other improvements to unit tests and documentation ([#106] and [#115]) 394 395[#24]: https://github.com/rust-lang-nursery/bitflags/pull/24 396[#106]: https://github.com/rust-lang-nursery/bitflags/pull/106 397[#112]: https://github.com/rust-lang-nursery/bitflags/pull/112 398[#115]: https://github.com/rust-lang-nursery/bitflags/pull/115 399 400## How to update your code to use associated constants 401Assuming the following structure definition: 402```rust 403bitflags! { 404 struct Something: u8 { 405 const FOO = 0b01, 406 const BAR = 0b10 407 } 408} 409``` 410In 0.9 and older you could do: 411```rust 412let x = FOO.bits | BAR.bits; 413``` 414Now you must use: 415```rust 416let x = Something::FOO.bits | Something::BAR.bits; 417``` 418 419# 0.9.1 420- Fix the implementation of `Formatting` traits when other formatting traits were present in scope ([#105]) 421 422[#105]: https://github.com/rust-lang-nursery/bitflags/pull/105 423 424# 0.9.0 425- **[breaking change]** Use struct keyword instead of flags to define bitflag types ([#84]) 426 427- **[breaking change]** Terminate const items with semicolons instead of commas ([#87]) 428 429- Implement the `Hex`, `Octal`, and `Binary` formatting traits ([#86]) 430 431- Printing an empty flag value with the `Debug` trait now prints "(empty)" instead of nothing ([#85]) 432 433- The `bitflags!` macro can now be used inside of a fn body, to define a type local to that function ([#74]) 434 435[#74]: https://github.com/rust-lang-nursery/bitflags/pull/74 436[#84]: https://github.com/rust-lang-nursery/bitflags/pull/84 437[#85]: https://github.com/rust-lang-nursery/bitflags/pull/85 438[#86]: https://github.com/rust-lang-nursery/bitflags/pull/86 439[#87]: https://github.com/rust-lang-nursery/bitflags/pull/87 440 441# 0.8.2 442- Update feature flag used when building bitflags as a dependency of the Rust toolchain 443 444# 0.8.1 445- Allow bitflags to be used as a dependency of the Rust toolchain 446 447# 0.8.0 448- Add support for the experimental `i128` and `u128` integer types ([#57]) 449- Add set method: `flags.set(SOME_FLAG, true)` or `flags.set(SOME_FLAG, false)` ([#55]) 450 This may break code that defines its own set method 451 452[#55]: https://github.com/rust-lang-nursery/bitflags/pull/55 453[#57]: https://github.com/rust-lang-nursery/bitflags/pull/57 454 455# 0.7.1 456*(yanked)* 457 458# 0.7.0 459- Implement the Extend trait ([#49]) 460- Allow definitions inside the `bitflags!` macro to refer to items imported from other modules ([#51]) 461 462[#49]: https://github.com/rust-lang-nursery/bitflags/pull/49 463[#51]: https://github.com/rust-lang-nursery/bitflags/pull/51 464 465# 0.6.0 466- The `no_std` feature was removed as it is now the default 467- The `assignment_operators` feature was remove as it is now enabled by default 468- Some clippy suggestions have been applied 469