I’m currently trying to develop a Rust crate; let’s call it my_awesome_crate for now. Currently, my concern is that it depends on wgpu. But I don’t want my crate to have wgpu as a dependency. Let me explain.
I want this to be my crates Cargo.toml
[package]
name = "my_awesome_crate"
[dependencies]
anyhow = "..."
...
This crate depends on wgpu, even though it isn’t inside my dependencies.
Now here is a root Cargo.toml of an example project that could use my crate
[package]
name = "example_project"
[dependencies]
wgpu = "..."
my_awesome_crate = "..."
Now, my_awesome_crate should use the wgpu crate from the root project. If the root Cargo.toml doesn’t have wgpu as a dependency, the build will simply fail.
Now, my question is if this is even possible.
I’m usually a C++ developer, so a in-house package-manager is new territory for me. I know you can do this in CMake, but is Cargo able to do this too?