Is Vec<bool> compiled to bit vector(32 bool/32bits)?

Hi, it is well known that bit vector save a lot of memory usage, so is Vec<bool> compiled to bit vector (32 bool/32bits) or 1 bool/32bits or 1bool/8bits? Thanks!

Given the experience in C++ with std::vector<bool> being specialized, and all the problems that causes, Rust intentionally decided that Rust's Vec<bool> will never do that.

You probably want a dedicated bit-vector crate.


So, is it 1 bool/32bits or 1bool/8bits?

One bool is 8 bits wide.

1 Like