Document many-target projects
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- rust
- Domain
- documentation
Research direction
Start with the Cargo targets documentation at cargo/reference/cargo-targets.html#binaries and review the explanations of main.rs, lib.rs, and binary targets. Add a clear explanation that each binary target is its own crate, that main.rs and lib.rs can coexist, and a simple many-target example with imports. Done means newcomers can follow the example without needing Discord.
Written by the indexing model from the issue text.
Description
I have to go to DIscord to ask even simplest questions.
I was trying to add a new binary target to my project, which currently only has main.rs. It didn't work out of the box - my use crate:: didn't work (now it's obvious). I looked for doc and found this: https://doc.rust-lang.org/cargo/reference/cargo-targets.html#binaries
Following things were properly documented so I found them:
- needed to change my
mod xtopub mod xin the source code - you need to use lib.rs for imports (this was pretty cryptic but I guessed it from "library's public API" wording)
What is not mentioned, and should:
- Every binary target is its own crate. This is not obvious at all. It's kinda obvious if you think about them as Linux object files, but "crate" is more abstract term created solely for Rust and it needs to be properly defined from the ground up.
- Main.rs and lib.rs are not mutually exclusive.
A simple example project repository, together with source files with proper imports, with multiple targets, main.rs and lib.rs, would resolve this issue in no time. "Cargo cookbook" in form of file directories on Github would be most useful and probably the best way to figure things out.
- Dominant language
- Rust
- Stars
- 15.5k
- Forks
- 3k
- Avg merge
- 23h 30m
- Merged PRs (30d)
- 51
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.
More from rust-lang/cargo
-
C-bug S-triage
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
A-completions C-bug S-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
C-bug S-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Command-fix
Difficulty 1/5 Under an hour Newbie friendliness 82/100
-
cargo remove prints "Removing X" for dependencies that never get removed when the command fails OpenC-bug Command-remove S-triage
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100