I'm not even sure exactly how to say this clearly in word without it being potentially confusing, so here is an example.
Ex. I'm using crate A.
Crate A depends on crate B.
I realize I need crate B also, can I somehow specify that I want to use whatever version of B that A is using?
Afaik that isn't possible. The inner dependency isn't in your control. What you can do is use the appropriate version of A that uses the version of B you want.
In Cargo.toml "1.2.1" means any version between 1.2.1 and 1.9999.9999.
Cargo tries to have only one version of every crate, so unless you set incompatible version, your crate and crate A will get the same one version of B.
So if A::B is set to "1.2.1", you can also set "1.2.1" or "1.0.0", or "1.*" in your Cargo.toml. It's likely that you will get some other version (like 1.3.5), but both crates will share the dependency. Unless A::B is set to 1.2.1 and your create requires 2.0.0 or 0.0.1.
It's not doing that. The version of B that A is using is 0.18.0. If I do B = "0.18.0" then I get 0.18.0 and my code works. If I try "0" or "~0" or "^0" or "*", (all of which are semver compatible with 0.18.0 I believe), then I get the wrong version, and while compiling it shows
It's all explained in Specifying Dependencies - The Cargo Book . You can write "b" = ">=0" but that's probably not actually correct, since you'll likely not be compatible with all of those.
I've read the specifying dependencies page, but it doesn't have anything on how to do what I want (Have crate B use the same version as crate A's B uses), as far as I could see.
Look at the problem from the other direction. Go through all the versions of A and note down which version of B it uses. Then limit A to only those versions that use the same B as you are using directly.