Sha256: 730589695eb68dda21d0d9f69e90cbdbf9823b13d6f16c5f22b0083c00981813
Contents?: true
Size: 691 Bytes
Versions: 1
Compression:
Stored size: 691 Bytes
Contents
//! An example of implementing the `BitFlags` trait manually for a flags type. use std::str; use bitflags::bitflags; // Define a flags type outside of the `bitflags` macro as a newtype // It can accept custom derives for libraries `bitflags` doesn't support natively #[derive(zerocopy::IntoBytes, zerocopy::FromBytes, zerocopy::KnownLayout, zerocopy::Immutable)] #[repr(transparent)] pub struct ManualFlags(u32); // Next: use `impl Flags` instead of `struct Flags` bitflags! { impl ManualFlags: u32 { const A = 0b00000001; const B = 0b00000010; const C = 0b00000100; const ABC = Self::A.bits() | Self::B.bits() | Self::C.bits(); } } fn main() {}
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wasmtime-29.0.0 | ./ext/cargo-vendor/bitflags-2.8.0/examples/custom_derive.rs |