rust-lang / rust-lang/rust-by-example
the first example 'cargo test' can not work
Nobody has claimed this yet.
- Dominant language
- Handlebars
- Stars
- 8.1k
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Description
https://doc.rust-lang.org/stable/rust-by-example/testing/unit_testing.html
I just do copy the first unit test sample into a file named t.rs, then run 'cargo test', it report error.
After read the book, I change the process to
cargo new --lib add
cd add
vim src/lib.rs ## copy & paste the example code here
cargo test # it works now.
My suggestion is do a brief description about how to play the 'unittest' code, to let those readers who still not read the book can also complete the examples.
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 with the unit-testing example at the linked Rust by Example page and compare the standalone t.rs workflow with the cargo new --lib add workflow described in the issue. Add a brief explanation of the required Cargo project setup so readers can run the example with cargo test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100