mutability fixes
This commit is contained in:
parent
8b6987aced
commit
6476a1e378
1 changed files with 4 additions and 4 deletions
|
@ -55,8 +55,8 @@ fn main() {
|
||||||
|
|
||||||
This will print `The point is at (5, 0)`.
|
This will print `The point is at (5, 0)`.
|
||||||
|
|
||||||
Rust does not support mutability at the field level, so you cannot write
|
Rust does not support field mutability at the language level, so you cannot
|
||||||
something like this:
|
write something like this:
|
||||||
|
|
||||||
```rust,ignore
|
```rust,ignore
|
||||||
struct Point {
|
struct Point {
|
||||||
|
@ -82,8 +82,8 @@ fn main() {
|
||||||
|
|
||||||
point.x = 5;
|
point.x = 5;
|
||||||
|
|
||||||
let point = point; // this new binding is immutable
|
let point = point; // this new binding can’t change now
|
||||||
|
|
||||||
point.y = 6; // this causes an error, because `point` is immutable!
|
point.y = 6; // this causes an error
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue