My workspace looks like this:
workspace
|--other_crate <== existing crate relying on tokio
|-- Cargo.toml
|--my_crate <== this is a new crate called using "cargo new --lib"
|-- Cargo.toml
|--Cargo.lock
|--Cargo.toml
I want to add this dependency from Cargo.lock in my new crate:
[[package]]
name = "tokio"
version = "1.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9d0183f6f6001549ab68f8c7585093bb732beefbcf6d23a10b9b95c73a1dd49"
dependencies = [
...
]
I would like my_crate to always rely on the same tokio version as other_crate, what is the best way to do it? I am guessing Cargo.lock is the solution to do this, but there is not much documentation on how to do so. In other words, is there a solution something like this in my_crate/Cargo.toml:
...
[dependencies]
tokio = {// refer to Cargo.lock's tokio entry and use it}
...
Currently, I just manually looking up Cargo.lock's entry and manually copying the version. However, if I have N crates relying on the same entry, ensuring that there is version consistency (whenever Cargo.lock needs to be updated) will be backbreaking work...