Expand description

The variant_size_differences lint detects enums with widely varying variant sizes.


enum En {
    VBig([u8; 1024]),



It can be a mistake to add a variant to an enum that is much larger than the other variants, bloating the overall size required for all variants. This can impact performance and memory usage. This is triggered if one variant is more than 3 times larger than the second-largest variant.

Consider placing the large variant’s contents on the heap (for example via Box) to keep the overall size of the enum itself down.

This lint is “allow” by default because it can be noisy, and may not be an actual problem. Decisions about this should be guided with profiling and benchmarking.