You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/expressions/operator-expr.md
+10-2Lines changed: 10 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -170,10 +170,13 @@ r[expr.deref.intro]
170
170
The `*` (dereference) operator is also a unary prefix operator.
171
171
172
172
r[expr.deref.result]
173
-
When applied to a [pointer](../types/pointer.md) it denotes the pointed-to location.
173
+
When applied to a [pointer](../types/pointer.md)or [`Box`], it denotes the pointed-to location.
174
174
175
175
r[expr.deref.mut]
176
-
If the expression is of type `&mut T` or `*mut T`, and is either a local variable, a (nested) field of a local variable or is a mutable [place expression], then the resulting memory location can be assigned to.
176
+
If the expression is of type `&mut T`, `*mut T`, or `Box<T>`, and is either a local variable, a (nested) field of a local variable or is a mutable [place expression], then the resulting memory location can be assigned to.
177
+
178
+
r[expr.deref.box]
179
+
When applied to a [`Box`], the resultant place may be [moved from].
177
180
178
181
r[expr.deref.safety]
179
182
Dereferencing a raw pointer requires `unsafe`.
@@ -182,11 +185,14 @@ r[expr.deref.traits]
182
185
On non-pointer types `*x` is equivalent to `*std::ops::Deref::deref(&x)` in an [immutable place expression context](../expressions.md#mutability) and `*std::ops::DerefMut::deref_mut(&mut x)` in a mutable place expression context.
183
186
184
187
```rust
188
+
# structNoCopy;
185
189
letx=&7;
186
190
assert_eq!(*x, 7);
187
191
lety=&mut9;
188
192
*y=11;
189
193
assert_eq!(*y, 11);
194
+
letz=Box::new(NoCopy);
195
+
let_:NoCopy=*z;
190
196
```
191
197
192
198
r[expr.try]
@@ -1083,6 +1089,7 @@ As with normal assignment expressions, compound assignment expressions always pr
0 commit comments