3.1 Structures "because we used that field from `point`" should be "`another_point`"
Basiliotornado opened this issue · 1 comments
Basiliotornado commented
At least, I'm pretty sure.
Line for reference:
// Instantiate a `Point`
let point: Point = Point { x: 10.3, y: 0.4 };
let another_point: Point = Point { x: 5.2, y: 0.2 };
// Access the fields of the point
println!("point coordinates: ({}, {})", point.x, point.y);
// Make a new point by using struct update syntax to use the fields of our
// other one
let bottom_right = Point { x: 5.2, ..another_point };
// `bottom_right.y` will be the same as `point.y` because we used that field
// from `point`
println!("second point: ({}, {})", bottom_right.x, bottom_right.y);
Which prints
point coordinates: (10.3, 0.4)
second point: (5.2, 0.2)
As you can see, it is the same as another_point.y, and not point.y :)
daniel-pg commented
I was about to report the same issue 😅
The comment should be changed to:
// `bottom_right.y` will be the same as `another_point.y` because we used that field
We could also change the code, but then the println! wouldn't make sense because it was supposed to print the values of the "second" point (although a third is created).