No, there is no way to specify the version for a dependency's (optional) dependency. This makes sense, as your dependency run their tests only against the version they specify in their Cargo.toml
. In this case, as it appears everything you're doing uses open source, you could fork barcoders
, update the dependency, run the test suite and if it passes, use your fork. It would also be polite to open an issue in that case.
If barcoders
wasn't open-source, so you couldn't fork it, your best bet would be to switch to the version of image
that barcoders
uses. If your crate is a library, it may be annoying to expose a public interface that uses outdated libraries, but that's life. The "proper" solution to this problem is to wait until image has a 1.0
release, which is basically a forward compatibility promise, then barcoders
can specify image = "^1"
(i.e. >=1.0.0 <2.0.0). I mention this "solution" only because you appear to have commit privileges on barcoders
, in fact you solved your own problem by updating the image
dependency in barcoders
.
As one of the comments points out, this version compatibility issue is less fragile that it at first seems. So long as types from different versions of some dependency crate don't cross api boundaries, your project can include any number of versions of that dependency simultaneously. Working with multiple versions of libraries took some work from the rust team on name mangling, which you can read about here