Afaik Cargo does it out of the box, based on Cargo.lock.
UPDATE: This doc page seems to confirm that: <https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lo...>
Disregarding the rev attribute?