title: How can a Rust program access metadata from its Cargo package?
body: <p>How do you access a Cargo package's metadata (e.g. version) from the Rust code in the package? In my case, I am building a command line tool that I'd like to have a standard <code>--version</code> flag, and I'd like the implementation to read the version of the package from <code>Cargo.toml</code> so I don't have to maintain it in two places. I can imagine there are other reasons someone might want to access Cargo metadata from the program as well.</p>