The compiler does a lot of optimizations automatically during the compilation process, but we can also activate some optimizations after the sources compiled. This technique called Link Time Optimizations (LTO) and applied after code linked and the whole program available. You can activate this optimization for Rust program by adding an extra section to the Cargo.toml file in your project:
[profile.release] lto = true
If you have already compiled the project with this optimization, force a complete rebuild of your project. But this option also takes much more time for compilation. This optimization does not necessarily improve the performance, but can help to reduce the size of a binary.
Normal Rust programs use panic macros for unhandled errors and print backtraces. For optimization, you can consider turning this off. Let's look at this technique in the next section.