▲ | steveklabnik a day ago | |||||||||||||||||||||||||
Note that in the output, there is rand 0.9.0, and two instances of rand_core 0.9.3. You may have thought it selected two versions because you missed the _core there. > So there's no difference at all between "0", "0.9" and "0.9.3" in cargo.toml No, there is a difference, in particular, they all specify different minimum bounds. The trick is that these are using the ^ operator to match, which means that the version "0.9.3" will satisfy all of those constraints, and so Cargo will select 0.9.3 (the latest version at the time I write this comment) as the one version to satisfy all of them. Cargo will only select multiple versions when it's not compatible, that is, if you had something like "1.0.0" and "0.9.0". > Surely there's some way to actually require an exact version? Yes, you'd have to use `=`, like `=0.9.3`. This is heavily discouraged because it would lead to a proliferation of duplication in dependency versions, which aren't necessarily unless you are trying to avoid some sort of specific bugfix. This is sometimes done in applications, but basically should never be done in libraries. | ||||||||||||||||||||||||||
▲ | 0xffff2 a day ago | parent [-] | |||||||||||||||||||||||||
Sorry, I don't understand the "^ operator" in this context. Do I understand correctly that cargo will basically select the latest release that matches within a major version, so if I have two crates that specify "0.8" and "0.7.1" as dependencies then the compiler will use "0.8.n" for both? And then if I add a new dependency that specifies "0.9.5", all three crates would use "0.9.5"? Assuming I have that right, I'm quite surprised that it works in practice. | ||||||||||||||||||||||||||
|