Enhancement Request: Chapter 04-02 note explaining println! is special
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 68/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- rust
- Domain
- documentation
Research direction
Open the linked Chapter 04-02 section on references and borrowing in the latest main branch, and locate the point immediately before “Mutable References.” Add a brief note explaining that println! and some standard macros implicitly borrow values, and verify that the rendered book presents the clarification in the intended location.
Written by the indexing model from the issue text.
Description
- I have searched open and closed issues and pull requests for duplicates, using these search terms:
- chapter 04
- println!
- I have checked the latest
mainbranch to see if this has already been fixed, in this file:- it is not
URL to the section(s) of the book with this problem:
https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html
Description of the problem:
When learning about references and borrowing for the first time, println! is confusing as it appears to take ownership. In fact it does not, like several other macros. There is a good discussion in the answer on StackOverflow on this topic at
https://stackoverflow.com/questions/30450399/does-println-borrow-or-own-the-variable
Suggested fix:
Add a brief note box just before "Mutable References", something such as this:
It may seem as if all the println! macros we've seen so far take ownership. In fact, println! and several other standard macros implicitly use a reference for convenience. If you explicitly pass a reference the code works just the same. (Try it!)
- Dominant language
- Rust
- Stars
- 18.3k
- Forks
- 4.1k
- Avg merge
- 14m
- Merged PRs (30d)
- 1
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/book
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 1/5 Under an hour Newbie friendliness 92/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