Let's say there is a library fancy_math
.
fancy_calculus 1.0
depends on fancy_math 1.8
.
However, due to some breaking changs introduced in fancy_math 2.0
, fancy_calculus 1.0
can only depend on fancy_math 1.8
.
There's also a library fancy_physics 1.0
that is built upon fancy_math 2.0
, and will not work with earlier versions.
With Cargo, if I wanted to use both fancy_calculus 1.0
and fancy_physics 1.0
, will Cargo be able to infer that I need both fancy_math
versions 1.8
and 2.0
and build them separately? Is there some namespace-mangling done?
From the Cargo reference:
If multiple packages have a common dependency with semver-incompatible versions, then Cargo will allow this, but will build two separate copies of the dependency. For example:
# Package A [dependencies] rand = "0.7" # Package B [dependencies] rand = "0.6"
The above will result in Package A using the greatest
0.7
release (0.7.3
at the time of this writing) and Package B will use the greatest0.6
release (0.6.5
for example). This can lead to potential problems, see the Version-incompatibility hazards section for more details.
However, as specified in the "Version-incompatibility hazards" section, you will not be able to use types of fancy_math
that fancy_calculus
exports where a type of fancy_math
that fancy_physics
exports is expected, or the opposite.