Skip to content
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

The book chapter on struct would benefit from clarifying that the type of struct fields can be mut #30254

Closed
hsivonen opened this issue Dec 7, 2015 · 1 comment

Comments

@hsivonen
Copy link
Member

hsivonen commented Dec 7, 2015

As a newbie, I made the mistake that can be witnessed with the field slice in this question about other stuff.

The way this happened is that I vaguely remembered that you can't use mut when specifying the fields of struct and to make sure, I looked up the struct chapter in the book. Sure enough, it said "Mutability is a property of the binding, not of the structure itself."

Now, as a newbie, I thought this forbade mut in field definitions altogether even though it only forbids mut to the left of the colon and you can still have &mut as the type to the right of the colon.

It would be nice if this was briefly clarified for the benefit of newbies looking stuff up piecemeal and not properly thinking about stuff in the context of what has previously been said in an earlier chapter.

@steveklabnik
Copy link
Member

👍

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

No branches or pull requests

3 participants