rust-lang / rust-lang/rust-by-example
Literals and operators - Wording - need to tell the compiler the type
Nobody has claimed this yet.
- Dominant language
- Handlebars
- Stars
- 8.1k
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Description
Please review below for any doc changes needed
At https://doc.rust-lang.org/rust-by-example/primitives/literals.html
It says We need to tell the compiler the type of the literals we use.
I felt that is must or have to ( though it dint say so ), otherwise may tell or could tell can be used
However, it works without telling the type
There is no need to tell, it can infer.
So doc should be changed?
==
// Integer addition
println!("1 + 2 = {}", 1 + 2); // =============== i wrote this
println!("1 + 2 = {}", 1u32 + 2);
1 + 2 = 3 // =============== i wrote this
1 + 2 = 3
==
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
Open the Rust by Example page at doc.rust-lang.org/rust-by-example/primitives/literals.html and review the sentence about specifying literal types alongside the integer-addition examples. Check Rust's type inference behavior, then revise the wording if needed so it accurately explains when an explicit type is required or optional; the page should remain clear and consistent with its examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100