Is there any reason `size_of::<(bool, bool)>()` has to be 2 instead of 1?

⚓ Rust    📅 2025-08-16    👤 surdeus    👁️ 5      

surdeus

A bool only has 2 possibilities: true or false. So a tuple of 2 bools only has 4 possibilities, well under 256 maximum possibilities that 8 bits can afford.

Rust also has size optimization for NonZero and reference types.

So why doesn't bool benefit from such optimization?

3 posts - 3 participants

Read full topic

🏷️ Rust_feed