Accessing one crate through another in Rust

Viewed 110

I want to port in serde_json through cucumber. gherkin_rust v0.10.1 lists it under "[build-dependencies]". How do I access it without adding it to the toml file / using an extern crate call?

 └── cucumber v0.10.2
    ├── gherkin_rust v0.10.1
    │   ├── peg v0.6.3
    │   │   ├── peg-macros v0.6.3 (proc-macro)
    │   │   │   ├── peg-runtime v0.6.3
    │   │   │   ├── proc-macro2 v1.0.32 (*)
    │   │   │   └── quote v1.0.10 (*)
    │   │   └── peg-runtime v0.6.3
    │   ├── textwrap v0.12.1
    │   │   └── unicode-width v0.1.9
    │   ├── thiserror v1.0.30
    │   │   └── thiserror-impl v1.0.30 (proc-macro)
    │   │       ├── proc-macro2 v1.0.32 (*)
    │   │       ├── quote v1.0.10 (*)
    │   │       └── syn v1.0.81 (*)
    │   └── typed-builder v0.7.1 (proc-macro)
    │       ├── proc-macro2 v1.0.32 (*)
    │       ├── quote v1.0.10 (*)
    │       └── syn v1.0.81 (*)
    │   [build-dependencies]
    │   ├── heck v0.3.3
    │   │   └── unicode-segmentation v1.8.0
    │   ├── quote v1.0.10 (*)
    │   ├── serde v1.0.130
    │   │   └── serde_derive v1.0.130 (proc-macro)
    │   │       ├── proc-macro2 v1.0.32 (*)
    │   │       ├── quote v1.0.10 (*)
    │   │       └── syn v1.0.81 (*)
    │   ├── serde_json v1.0.68
    │   │   ├── itoa v0.4.8
    │   │   ├── ryu v1.0.5
    │   │   └── serde v1.0.130 (*)
    │   └── syn v1.0.81 (*)
   
1 Answers

You can not access to it through another crate unless that other crate reexports it publicly (ex pub use::cool_crate).

Just add whatever you need to your Cargo.toml. Notice that dependencies are not used more than once, so there should not be any difference but the usage through namespacing.

Related