Cargo sets the CARGO_PKG_VERSION environment variable when it invokes rustc. You can use this to define a const in your executable to show it to the user. In libraries this is also useful.
Please note that this line of code will yield an error if the environment variable isn't defined, for example if you execute rustc directly without cargo.