Skip to content

Minor change to 8.3#4687

Open
cobalt32 wants to merge 1 commit intorust-lang:mainfrom
cobalt32:main
Open

Minor change to 8.3#4687
cobalt32 wants to merge 1 commit intorust-lang:mainfrom
cobalt32:main

Conversation

@cobalt32
Copy link

The mutable reference goes out of scope at the end of the for loop, so all of these changes are safe and allowed by the borrowing rules.

is changed to

The mutable reference goes out of scope after each iteration of the for loop, so all of these changes are safe and allowed by the borrowing rules.

I believe this wording better clarifies why the changes are safe. With the old wording, the reader may be led to believe that every mutable reference remains in scope until the end of the for loop. This would not be allowed by the borrow checker. The change makes it clear that each mutable reference goes out of scope after each iteration.

I'm sure most readers would figure this out on their own, but I figured I'd submit this in case it is worth changing.

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.

1 participant