Crates.io | bitflags-derive |
lib.rs | bitflags-derive |
version | |
source | src |
created_at | 2025-02-05 10:10:53.896375+00 |
updated_at | 2025-02-26 05:07:53.001287+00 |
description | bitflags-aware #[derive] macros. |
homepage | |
repository | https://github.com/bitflags/bitflags-derive |
max_upload_size | |
id | 1543801 |
Cargo.toml error: | TOML parse error at line 22, column 1 | 22 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
bitflags-derive
This project is a set of custom derive attributes for bitflags
that generates flags-aware implementations.
Add bitflags-derive
to your Cargo.toml
alongside bitflags
:
[dependencies.bitflags-derive]
version = "0.0.4"
[dependencies.bitflags]
version = "2"
Inside the bitflags!
macro, add a #[derive]
attribute with any traits from bitflags-derive
that you'd like to support:
#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate bitflags_derive;
bitflags! {
#[derive(FlagsDisplay, FlagsFromStr)]
struct MyFlags: u8 {
const A = 1;
const B = 1 << 1;
const C = 1 << 2;
}
}
let flags = "A | B".parse::<MyFlags>()?;
assert_eq!("A | B", flags.to_string());
See the docs for details on all supported attributes.