Hi! I'd like to detect a lib dependency version in code, how could I do that?
Context: I'm in the process of creating a lib with shared functionality within my company, so other projects can use it.
For my bin projects, I use the git version which works wonderfully:
pub const VERSION: &str = git_version::git_version!(
args = ["--tags", "--dirty", "--broken"],
fallback = "out-of-tree"
);
But now that this lib crate is being used in Cargo.toml as my-lib = { path = "../my-lib" version = "0.1" }
, that returns out-of-tree
... So, I think I'll have to settle on the semver of the lib.
What I need is to log on the bin whether it was compiled with 0.1.0
or 0.1.35
, for example:
println!(
"Starting up version: {} (my-lib: ?)", crate::VERSION, my_lib::VERSION
);
Would it be possible?
Thanks!