rust-lang / rust-lang/rust-by-example
19.1 Box, stack and heap - Wrong output
Nobody has claimed this yet.
- Dominant language
- Handlebars
- Stars
- 8.1k
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Description
From example here
we have output
Point occupies 16 bytes on the stack
Rectangle occupies 32 bytes on the stack
Boxed point occupies 8 bytes on the heap
Boxed rectangle occupies 8 bytes on the heap
Boxed box occupies 8 bytes on the heap
Unboxed point occupies 16 bytes on the stack
Boxed point don't occupies 8 bytes on the heap. Pointer to point occupies 8 bytes on the stack, point on the heap occupies 16 bytes.
Boxed rectangle don't occupies 8 bytes on the heap. Pointer to rectangle occupies 8 bytes on the stack, rectangle on the heap occupies 32 bytes.
First box occupies 8 bytes on stack, second box occupies 8 bytes on heap and point occupies 16 bytes on heap.
From current text it looks if you put 2MB on heap they will only take 8 bytes on heap, because rectangle who is 32 bytes only take 8 bytes on heap.
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
Start with the Rust by Example std/box.html example linked in the issue and compare its output and explanation of stack and heap sizes with the reported behavior. Update the wording and output so pointer sizes are distinguished from the sizes of boxed values, then verify the example’s displayed output.
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
- Mostly clear
- Newbie friendliness
- 45/100