From 57c203ef7fdd6efdecbece708df44e7944a3f317 Mon Sep 17 00:00:00 2001 From: Jesse Jones Date: Sun, 18 Nov 2012 15:26:12 -0800 Subject: [PATCH] Documented copy, ref, move in patterns. Closes #3337 --- doc/rust.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/rust.md b/doc/rust.md index dddd372dcc8e..5936f6b2848b 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -2206,7 +2206,12 @@ fn main() { } ~~~~ -A pattern that's just a variable binding, +Patterns that bind variables default to binding to a copy of the matched value. This can be made +explicit using the ```copy``` keyword, changed to bind to a borrowed pointer by using the ```ref``` +keyword, or to a mutable borrowed pointer using ```ref mut```, or the value can be moved into +the new binding using ```move```. + +A pattern that's just an identifier, like `Nil` in the previous answer, could either refer to an enum variant that's in scope, or bind a new variable.