rust-lang / rust-lang/book

Mutable reference/mutable variable clarification in Chapter 4.2

Open
#3,754 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
18.3k
Forks
4.1k
Avg merge
14m
Merged PRs (30d)
1

Description

Hello.
I have started learning Rust and have a small suggestion for chapter 4.2.
I think that it's worth it to directly state that you can create a mutable reference only to a mutable variable, meaning that you can't create a mutable reference to an unmutable variable.
After reading the chapter I was left with that question in mind ("What if I create a mutable reference to an unmutable variable? Is it even possible?"). Of course that I quickly opened the compiler and checked for my self, but still I think that it's worth adding.
Thanks!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open Chapter 4.2 and review the section discussing mutable variables and references. Check how it currently explains creating mutable references, then clarify the relationship between a mutable reference and the mutability of its referenced variable. Done means the chapter directly answers whether a mutable reference can be created from an immutable variable.

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
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.