3 ms·
> Rust is good but not great. Being able to import two major versions of a lib into the same compilation unit (am I understanding this correctly?) is a huge win
by the_mitsuhiko 9y ago
> Rust is good but not great. Being able to import two major versions of a lib into the same compilation unit (am I understanding this correctly?) is a huge win.
The one time I needed that I found a pretty good workaround: you make two crates `helper_old` and `helper_new` and have each depend on different versions of that crate. Then I just pub re-exported the crate it depends on.
That way your other crate can now depend on two different versions of that dependency.
- sitkack 9y agoGenius! I trust you will be authoring a new book "RustOps in Practice".
- rickycook 9y agoseems like that’d be a decent compiler trick
- necubi 9y agoThis is also the standard approach in the java world, where it's known as "shading."
- WatchDog 9y ago"Shading" obviosuly comes from the plugin of the same name. But I think of shading to refer more to the practice of repacking classes into a single jar, than the renaming of package name spaces. As far as the standard approach to supporting muliple library versions in one application, i think OSGI is probably the closest thing to a workable solution.