Allow dependencies that only apply to specific cargo targets (bin, example, etc.)
Open
Nobody has claimed this yet.
A-crate-dependencies
C-feature-request
E-hard
S-needs-design
- Dominant language
- Rust
- Stars
- 15.5k
- Forks
- 3k
- Avg merge
- 23h 30m
- Merged PRs (30d)
- 51
Description
Past RFCs
- rust-lang/rfcs#2887
- rust-lang/rfcs#3020
- rust-lang/rfcs#3374
Related requests
- rust-lang/cargo#4663
Use case: I have a library that also produces an executable. The executable needs env_logger in order to be able to log, the library shouldn't carry that dependency though, as it pulls in all sorts of crates (e.g. regex (?)).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the linked RFCs and related issue rust-lang/cargo#4663 to understand the proposed target-specific dependency behavior and existing decisions. Done means Cargo can express dependencies used only by binaries, examples, or other specific targets without adding them to the library's dependency set.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100