pub trait Element: Sized {
type W: Copy;
type R: Copy;
// Required methods
fn width(_: Self::W) -> usize;
fn from_bits(bits: u64) -> Option<Self::R>;
fn to_bits(_: Self::R) -> u64;
}
Expand description
The “element type” of a bitmap
Types implementing this trait can be stored in a bitmap. However, you shouldn’t need to
implement this trait yourself if you only care about semantics-free bits: use one of the
fixed-width types defined here, such as OneBit
, TwoBits
, etc, or the DynamicWidth
type.
However, this can be used to make the Bitmap
strongly typed storage for types such as those
generated by the bitflags!
macro.
Required Associated Types§
Required Methods§
Sourcefn width(_: Self::W) -> usize
fn width(_: Self::W) -> usize
Return the width of values of this type, in bits.
This method is called somewhat frequently, on almost every access to the Bitmap
. However,
the value it is passed is only ever specified in one place: Bitmap::from_storage
.
This should never return a value greater than 64, and should always return the same value
for the same Bitmap
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.