How to get crate version in Rust?Cargo does pass some metadata to the compiler through environment variables. The compiler environment is populated by
fill_envin Cargo's code. This code has become more complex since earlier versions, and the entire list of variables is no longer obvious from it because it can be dynamic.
Below is a set of variables available:
You can access environment variables using the
env!()macro. If you want you compiler to compile without Cargo you can use