For my fellow Rust enthusiasts, it is well-known that the compiler is able to perform some optimizations, called “niche”, that can make, for example, an Option<NonZeroU32>
fits on 32-bits. In this article, I will try to understand how it extends to some other enum types, and how the compiler achieves this.
Tag: llvm
In this article, we will consider a simple program computing the sum of a vector numbers, see the differences of performances when running it with cargo run
and cargo run --release
. We will then try to understand where this difference comes from and have some surprises.