macro_rules! generate_small_bit_map_struct {
(struct $name:ident<$bits:tt>) => { ... };
}Expand description
Generate a typed SmallBitMap wrapper struct.
This macro creates a new struct that wraps a SmallBitMap with a specific
number of bits. The generated struct implements Deref and DerefMut
to provide transparent access to the underlying SmallBitMap methods.
This is useful for creating type-safe bitmap wrappers with custom inline storage.
§Syntax
use ranged_bitmap::generate_small_bit_map_struct;
generate_small_bit_map_struct!(struct StructName<256>);§Arguments
struct $name:ident- The name of the struct to generate<$bits:tt>- The number of bits the bitmap should contain
§Generated Code
The macro generates:
- A struct wrapping
SmallBitMap<BLOCKS>whereBLOCKSis computed frombits - A
new()constructor function DerefandDerefMutimplementations for transparent method access
§Example
use ranged_bitmap::generate_small_bit_map_struct;
generate_small_bit_map_struct!(struct MySmallBitmap<256>);
let mut bitmap = MySmallBitmap::new();
bitmap.set(10); // Uses Deref to access SmallBitMap methods
bitmap.set_range(50, 100);
assert!(bitmap.get(10));
assert!(bitmap.check_range_is_set(50, 100));§Performance
The generated wrapper has zero runtime overhead: all method calls
are directly forwarded to the underlying SmallBitMap through
deref coercion, which is optimized away by the compiler.