Skip to content

Commit 57c203e

Browse files
committed
Documented copy, ref, move in patterns.
Closes #3337
1 parent e46de53 commit 57c203e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

doc/rust.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -2206,7 +2206,12 @@ fn main() {
22062206
}
22072207
~~~~
22082208

2209-
A pattern that's just a variable binding,
2209+
Patterns that bind variables default to binding to a copy of the matched value. This can be made
2210+
explicit using the ```copy``` keyword, changed to bind to a borrowed pointer by using the ```ref```
2211+
keyword, or to a mutable borrowed pointer using ```ref mut```, or the value can be moved into
2212+
the new binding using ```move```.
2213+
2214+
A pattern that's just an identifier,
22102215
like `Nil` in the previous answer,
22112216
could either refer to an enum variant that's in scope,
22122217
or bind a new variable.

0 commit comments

Comments
 (0)