rust-lang / rust-lang/book

RefCell needs more explanation: heap or stack?

Open
#1,963 0 comments 13 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

The RefCell chapter gives the reader an impression that RefCell is no different from Box other than the additional support of runtime mutability check. However there's another big difference: Box manages object on the heap while RefCell is just a stack variable wrapper. I think this needs to be clearly stated when introducing RefCell to the reader, otherwise it can cause confusions (see this discussion in the forum).

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

Start with the linked RefCell chapter in The Rust Programming Language and review how RefCell is compared with Box. Update the explanation to clearly distinguish RefCell's runtime mutability checks from Box's heap allocation, so readers understand the difference and the chapter addresses the reported confusion.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.