Given the original intent of importing non-exposed dependencies from a crate (such as pathfinding
) into a dependent project, that is currently not allowed. If a dependency is not re-exported by the crate, that makes it more of an implementation detail than part of the API. Allowing a dependent to access any "sub-dependency" would therefore be catastrophic.
In this case however, since num_traits
is clearly used in the crate's public API, it also makes sense for the dependent to have access to it. As it is, you are expected to add the dependency in your own project, while taking care to keep a compatible version. Otherwise, cargo might end up building duplicate dependencies.
[dependencies]
num_traits = "0.1"
In order to avoid this, pathfinding
would benefit from exporting its own num_traits
, as below. PR #6 was created for this purpose, and has been merged into version 0.1.12 (thanks, @SamuelTardieu).
pub extern crate num_traits;
With that done, you can now do exactly as written at the end of your question:
use pathfinding::num_traits::Zero;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…