Skip to content

bitflags/bitflags-derive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bitflags-derive

ci

This project is a set of custom derive attributes for bitflags that generates flags-aware implementations.

Usage

Add bitflags-derive to your Cargo.toml alongside bitflags:

[dependencies.bitflags-derive]
version = "0.0.1"

[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(FlagsDebug)]
    struct Flags: u8 {
        const A = 1;
        const B = 1 << 1;
        const C = 1 << 2;
    }
}

// The regular `#[derive(Debug)]` would produce "Flags(A | B)" here
assert_eq!("A | B", format!("{:?}", Flags::A | Flags::B));

See the docs for details on all supported attributes.

About

#[derive] traits for types generated by bitflags

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Languages