macro_rules! known_deep_size {
($size:expr; $($({$($gen:tt)*})? $type:ty,)+) => { ... };
($size:expr; $($({$($gen:tt)*})? $type:ty),+) => { ... };
}
Expand description
A macro to generate an impl for types with known inner allocation sizes.
Repurposed from the heapsize
crate
Usage:
struct A(u32);
struct B(A, char);
struct C(Box<u32>);
known_deep_size!(0; A, B); // A and B do not have any allocation
known_deep_size!(4; C); // C will always have an allocation of 4 bytes