Rust Get Crate Version

[Solved] Rust Get Crate Version | Rust - Code Explorer | yomemimo.com
Question : rust get crate version

Answered by : puzzled-peacock-2hd2cqnzz70w

const VERSION: &'static str = env!("CARGO_PKG_VERSION");
const OPTION_VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSION");
// ...
println!("MyProgram v{}", VERSION);
println!("MyProgram v{}", OPTION_VERSION.unwrap_or("unknown"));

Source : https://stackoverflow.com/questions/27840394/how-can-a-rust-program-access-metadata-from-its-cargo-package | Last Update : Fri, 09 Oct 20

Answers related to rust get crate version

Code Explorer Popular Question For Rust