Re:Cargo: predictable dependency management
by Siecje on Thursday May 05, 2016 @04:00PM
(#11639243)
How does Cargo manage the case when dependencies X and Y both require a different version of dependency Z?
[ Parent
| on HN ]
Re:Cargo: predictable dependency management
by steveklabnik on Thursday May 05, 2016 @04:01PM
(#11639249)
It attempts to unify them if it can, but if they cannot be unified, it will include both versions.
Include both how? Make renamed copies to have two and modify the code to use the new names?
Re:Cargo: predictable dependency management
by steveklabnik on Thursday May 05, 2016 @05:02PM
(#11639647)
It doesn't have to do any renaming or modifying of names. Rust has a module system, so each dependency will use the version they need.
The only time it doesn't Just Work is if one of those crates re-exports a type from the sub-crate in a public manner, and then you try to call something from the other crate with a value of that type. You'll get a compile-time error about mismatched types.
But it sounds like that's what's going on. Using foo-1.1 in bar.rs and foo-2.2 in rabbit.rs.
Re:Cargo: predictable dependency management
by steveklabnik on Thursday May 05, 2016 @05:11PM
(#11639691)
Sure. That will Just Work in every case _except_ if bar and rabbit both re-export a type from foo, and you try to use them together. If they don't re-export anything, then it all works just fine. No renaming or transformations needed.