🚲

rustでビルド時にCargo.tomlからバージョン情報を取得する

に公開

env!で普通に取得できるらしい

pub const VERSION: &str = env!("CARGO_PKG_VERSION");

fn main() {
    println!("version: {}", VERSION);
}

これでこうなる。

> cargo run
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.07s
     Running `target/debug/play_ground`
version: 0.1.0

configとかの整合性とかで使えそう?

GitHubで編集を提案

Discussion