Hi!
I understand that the chapter is frozen at this point. Probably this makes the suggestion useless, feel free to close straight away.
I liked the following section on structs from the first edition:
Rust does not support field mutability at the language level, so you cannot write something like this:
> struct Point {
> mut x: i32, // This causes an error.
> y: i32,
> }
Mutability is a property of the binding, not of the structure itself. If you鈥檙e used to field-level mutability, this may seem strange at first, but it significantly simplifies things. It even lets you make things mutable on a temporary basis:
> struct Point {
> x: i32,
> y: i32,
> }
>
> fn main() {
> let mut point = Point { x: 0, y: 0 };
>
> point.x = 5;
>
> let point = point; // `point` is now immutable.
>
> point.y = 6; // This causes an error.
> }
I think it could be useful to keep it in addition to the example added per issue #769 .
Best,
Andrei
PS Love the book, love the language, I am so looking forward to doing something meaningful with it!!
Thank you for your kind words and this suggestion! I'm going to ask our editors if we can sneak in a tiny bit next time we're working on Chapter 5, we'll see what they say.
Most helpful comment
Thank you for your kind words and this suggestion! I'm going to ask our editors if we can sneak in a tiny bit next time we're working on Chapter 5, we'll see what they say.