mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-02-02 23:38:41 +08:00
Example Point changes coordinates.
When the implementation a point moves from tuple to struct, the point coordinates should remain the same to avoid confusion.
This commit is contained in:
parent
aad634e61d
commit
799b5034cc
@ -143,7 +143,7 @@ struct Point {
|
|||||||
y: f64,
|
y: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
let p1 = Point { x: 0.0, y: 0.0 };
|
let p1 = Point { x: 0.0, y: 5.0 };
|
||||||
```
|
```
|
||||||
|
|
||||||
Here’s what declaring a `struct` looks like:
|
Here’s what declaring a `struct` looks like:
|
||||||
@ -176,7 +176,7 @@ struct Point {
|
|||||||
y: f64,
|
y: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
let p1 = Point { x: 0.0, y: 0.0 };
|
let p1 = Point { x: 0.0, y: 5.0 };
|
||||||
let x = p1.x;
|
let x = p1.x;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user