iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🚲
Getting version information from Cargo.toml at build time in Rust
It seems you can get it normally with env!
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
fn main() {
println!("version: {}", VERSION);
}
This results in the following.
> cargo run
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.07s
Running `target/debug/play_ground`
version: 0.1.0
It seems useful for things like configuration consistency?
Discussion