Specify version of dependency of dependency

#1

Assuming I use two crates: Crate A (version “0.3.0”) depends on version crate B version “1.2.0” up to “1.5.3”.
Crate B doesn’t reexport the types.
So I use version “0.3.0” of crate A and version “1.3.0” ("=1.3.0") of crate B.
Can it be ensured, that crate A will use the same version of crate B, which is directly used (“1.3.0”)?
Else when using slightly wrong versions will likely cause errors, that some function is not implemented, because it’s implemented for a different version of the same crate.

#2

The crate should re-export the types. File a bug about this.

If it doesn’t, it’s enough to specify the same major version. Don’t use "=x" versions as it doesn’t help, and can only backfire by causing a conflict.

Cargo will use one version of a dependency per any major version requested. So you may end up with 1.x and 2.y, but you won’t have 1.x and 1.y.

Note that first non-zero number is the major version, so 0.3.x and 0.4.x are also two different major versions (like 3.x and 4.x).

#3

Reexporting seems not like a good general solution. When multiple crates implement something for the same crate, reexporting won’t help.
For example we have some math library, and there is one crate, which implements a physics library based on the math, one, which implements a rendering library, and maybe some more.
Reexporting does not help in such a case.

But it’s good to know, how versions are selected.