Bad code-section example
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 35/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- rust
- Domain
- documentation
Research direction
The disputed Rust snippet is in the guide’s “Borrowing Pointers” section; start there and compile it with each commented line enabled to confirm the behavior. Update the example and explanatory comments so they agree with the observed compiler behavior, then verify the guide renders correctly.
Written by the indexing model from the issue text.
Description
Hey! I'm a beginner, but something worked and on the guide it said it shouldn't have worked.
On the "Borrowing Pointers" section, we've been given this code section:
fn foo() {
let mut x = 5; // type: i32
{
let y = &mut x; // type: &mut i32
//x = 4; // Error - x has been borrowed
//println!("{}", x); // Error - requires borrowing x
}
x = 4; // OK - y no longer exists
}
First, on lines x = 4 and println!... the comment is a direct contradiction.
Second, uncommenting the println! does work. I'm not sure what that means though, but
something here is unclear.
EDIT: This is also true when uncommenting x = 4. I'm not really sure about the validity of this example.
Thank you!
- Dominant language
- Rust
- Stars
- 3.9k
- Forks
- 297
- PR merge metrics
- No merged PRs in 30d
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
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 nrc/r4cppp
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 38/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 42/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
trailofbits/dylint#2107 ·
Maintainers usually reply within 1 day
-
area:cli bug good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
arrays_zip with two same-named inputs fails with "ArrowArray struct has 2 children (expected 1)"Openbug requires-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/datafusion-comet#6251 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
bug false-positive harper-core linting
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Automattic/harper#4471 ·
Maintainers usually reply within 1 day