Skip to content

docs(ch04-02): clarify reference scope vs variable scope (#4706)#4778

Open
Dodothereal wants to merge 1 commit into
rust-lang:mainfrom
Dodothereal:fix/issue-4706-reference-scope-clarification
Open

docs(ch04-02): clarify reference scope vs variable scope (#4706)#4778
Dodothereal wants to merge 1 commit into
rust-lang:mainfrom
Dodothereal:fix/issue-4706-reference-scope-clarification

Conversation

@Dodothereal

Copy link
Copy Markdown

Fixes #4706

Summary

Chapter 4-2 introduces a non-lexical-lifetime-style scope for
references but does not flag the shift away from the lexical scope
used for variables in earlier chapters. Beginners coming from
other languages may conflate the two meanings.

This commit prepends one sentence that makes the distinction
explicit, leaving the substantive explanation unchanged.

Test plan

  • git diff: single file, 6 insertions, 4 deletions
  • left dprint fmt untouched (no other files changed)

AI assistance

Prepared with help from an AI coding assistant.

Fixes rust-lang#4706: the phrase 'a reference's scope starts from where it is
introduced' implicitly shifts the meaning of the word 'scope' from
the lexical (curly-bracket) scope used for variables to the
non-lexical lifetime-style scope used for references. Without
acknowledging the shift, beginners may conflate the two.

Prepend one sentence to the existing paragraph to make the
distinguishing factor explicit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ch04: clarify the difference between variable scope and reference scope

1 participant