1//! An example of implementing the `BitFlags` trait manually for a flags type.
2
3use std::str;
4
5use bitflags::bitflags;
6
7// Define a flags type outside of the `bitflags` macro as a newtype
8// It can accept custom derives for libaries `bitflags` doesn't support natively
9#[derive(zerocopy::AsBytes, zerocopy::FromBytes)]
10#[repr(transparent)]
11pub struct ManualFlags(u32);
12
13// Next: use `impl Flags` instead of `struct Flags`
14bitflags! {
15 impl ManualFlags: u32 {
16 const A = 0b00000001;
17 const B = 0b00000010;
18 const C = 0b00000100;
19 const ABC = Self::A.bits() | Self::B.bits() | Self::C.bits();
20 }
21}
22
23fn main() {}
24