[Solved] Avoid duplicate storing of version

#1

The version of an application typically needs to be in at least two places: the Cargo.toml file and a constant somewhere in order to be displayed to the user.

In other languages we can solve this problem with makefiles of various sorts.

What’s the right solution in the cargo world ? Does it still need to be defined ? Should we have a macro reading the Cargo.toml file ?

0 Likes

#2

Cargo sets CARGO_PKG_VERSION environment variable for you:

let version = env!("CARGO_PKG_VERSION");

Doc

6 Likes

#3

Awesome!

0 Likes

closed #4

This topic was automatically closed after 34 hours. New replies are no longer allowed.

0 Likes