I am using the recommended approach for getting the current cargo version:
env!("CARGO_PKG_VERSION")
inside of a public function in crate A
crate B
calls that public function, but the version returned is always that of crate A
. Is there anyway for CARGO_PKG_VERSION
to reflect the top level Cargo.toml version and not that of dependency crates?
I know I could run the same env!
command from crate B
but I'm trying to stay DRY since there are many other crates calling crate A
(a utility crate)
Update:
I see that if crate B
were to call a macro instead of a function from crate A
then the version would be produced for crate B
:
So I guess that is the only option? The problem with a macro is I don't want to lose the type hinting for my arguments I pass to it like I have with a function