File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -276,6 +276,25 @@ Mutable references will set the mode to `ref mut` unless the mode is already `re
276276which case it remains ` ref ` . If the automatically dereferenced value is still a reference,
277277it is dereferenced and this process repeats.
278278
279+ Move bindings and reference bindings can be mixed together in the same pattern, doing so will
280+ result in partial move of the object bound to and the object cannot be used afterwards.
281+ This applies only if the type cannot be copied.
282+
283+ In the example below, ` name ` is moved out of ` person ` , trying to use ` person ` as a whole or
284+ ` person.name ` would result in an error because of * partial move* .
285+
286+ Example:
287+
288+ ``` rust
289+ # struct Person {
290+ # name : String ,
291+ # age : u8 ,
292+ # }
293+ # let person = Person { name : String :: from (" John" ), age : 23 };
294+ // `name` is moved from person and `age` referenced
295+ let Person { name , ref age } = person ;
296+ ```
297+
279298## Wildcard pattern
280299
281300> ** <sup >Syntax</sup >** \
You can’t perform that action at this time.
0 commit comments