We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 61ca87c + 723ead6 commit c20e339Copy full SHA for c20e339
src/doc/book/structs.md
@@ -88,6 +88,35 @@ fn main() {
88
}
89
```
90
91
+Your structure can still contain `&mut` pointers, which will let
92
+you do some kinds of mutation:
93
+
94
+```rust
95
+struct Point {
96
+ x: i32,
97
+ y: i32,
98
+}
99
100
+struct PointRef<'a> {
101
+ x: &'a mut i32,
102
+ y: &'a mut i32,
103
104
105
+fn main() {
106
+ let mut point = Point { x: 0, y: 0 };
107
108
+ {
109
+ let r = PointRef { x: &mut point.x, y: &mut point.y };
110
111
+ *r.x = 5;
112
+ *r.y = 6;
113
+ }
114
115
+ assert_eq!(5, point.x);
116
+ assert_eq!(6, point.y);
117
118
+```
119
120
# Update syntax
121
122
A `struct` can include `..` to indicate that you want to use a copy of some
0 commit comments