How to expose a dependency?

Assume there is a crate a that depended on crate b (via Git), and crate b depended on crate c (via crates).

How can functions in a use a (struct) type defined in c without adding c to a's dependency list?

Note: I have complete control of both crate a and b; that is, I can modify them easily. But I have no control over crate c.

You can re-export items from crate c in crate b.

For example,

// crate c

pub fn foo() {}

// crate b

// this is the re-export, note the `pub` modifier on the `use`
pub use crate_c::foo;

// crate a

use crate_b::foo;

fn main() {
    foo();
}
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.