Skip to content

Improve code in the intro. #18253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2014
Merged

Conversation

steveklabnik
Copy link
Member

All these stars aren't needed anymore.

@@ -471,7 +471,7 @@ fn main() {
spawn(proc() {
let mut array = number.lock();

(*(*array).get_mut(i)) += 1;
*(array.get_mut(i)) += 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Firstly, the parens aren't actually needed here, secondly (yay!) mutable indexing now works (works as well as immutable indexing, anyway, so the [] syntax can be used: (*array)[i] += 1.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh sweet! I didn't try hard enough i guess :)

@huonw
Copy link
Member

huonw commented Oct 23, 2014

r=me with more square brackets. 😄

All these stars aren't needed anymore.
steveklabnik added a commit to steveklabnik/hello_rust that referenced this pull request Oct 23, 2014
bors added a commit that referenced this pull request Oct 23, 2014
@bors bors closed this Oct 23, 2014
@bors bors merged commit 4a74af6 into rust-lang:master Oct 23, 2014
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.

3 participants