Skip to content

Commit 4445712

Browse files
jbclementsbrson
authored andcommitted
---
yaml --- r: 41672 b: refs/heads/master c: 0827582 h: refs/heads/master v: v3
1 parent 7d8f53f commit 4445712

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 42095221f496a4df47c3aee502a3509d969d268e
2+
refs/heads/master: 08275826ca44e736dab4925ea0450aeb731f1d80
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650

trunk/doc/tutorial.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,12 @@ Structs are quite similar to C structs and are even laid out the same way in
562562
memory (so you can read from a Rust struct in C, and vice-versa). Use the dot
563563
operator to access struct fields, as in `mypoint.x`.
564564

565-
Fields that you want to mutate must be explicitly marked `mut`.
565+
Inherited mutability means that any field of a struct may be mutable, if the
566+
struct is in a mutable slot (or a field of a struct in a mutable slot, and
567+
so forth).
568+
569+
A struct that is not mutable due to inherited mutability may declare some
570+
of its fields nevertheless mutable, using the `mut` keyword.
566571

567572
~~~~
568573
struct Stack {
@@ -572,7 +577,8 @@ struct Stack {
572577
~~~~
573578

574579
With a value of such a type, you can do `mystack.head += 1`. If `mut` were
575-
omitted from the type, such an assignment would result in a type error.
580+
omitted from the type, such an assignment to a struct without inherited
581+
mutability would result in a type error.
576582

577583
`match` patterns destructure structs. The basic syntax is
578584
`Name { fieldname: pattern, ... }`:

0 commit comments

Comments
 (0)