File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
8
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9
9
refs/heads/incoming: 44d4d6de762f3f9aae1fedcf454c66b79b3ad58d
10
- refs/heads/dist-snap: 42095221f496a4df47c3aee502a3509d969d268e
10
+ refs/heads/dist-snap: 08275826ca44e736dab4925ea0450aeb731f1d80
11
11
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
12
12
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
13
13
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
Original file line number Diff line number Diff line change @@ -562,7 +562,12 @@ Structs are quite similar to C structs and are even laid out the same way in
562
562
memory (so you can read from a Rust struct in C, and vice-versa). Use the dot
563
563
operator to access struct fields, as in ` mypoint.x ` .
564
564
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.
566
571
567
572
~~~~
568
573
struct Stack {
@@ -572,7 +577,8 @@ struct Stack {
572
577
~~~~
573
578
574
579
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.
576
582
577
583
` match ` patterns destructure structs. The basic syntax is
578
584
` Name { fieldname: pattern, ... } ` :
You can’t perform that action at this time.
0 commit comments