File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -127,13 +127,14 @@ let message = match maybe_digit {
127127> ```
128128
129129A pattern guard may refer to the variables bound within the pattern they follow .
130- When such a variable 's binding mode is by - value ,
131- a shared reference is taken to it before evaluating the guard .
132- When accessing the variable in the guard by shared reference ,
133- the shared reference taken before evaluating the guard is used .
134- Only when the guard expression evaluates to true is the by - value variable
135- moved , or copied , into the arm 's body . This allows shared borrows to be used
130+ Before evaluating the guard , a shared reference is taken to the part of the
131+ scrutinee the variable matches on . While evaluating the guard ,
132+ this shared reference is then used when accessing the variable .
133+ Only when the guard evaluates to true is the value moved , or copied ,
134+ from the scrutinee into the variable . This allows shared borrows to be used
136135inside guards without moving out of the scrutinee in case guard fails to match .
136+ Moreover , by holding a shared reference while evaluating the guard ,
137+ mutation inside guards is also prevented .
137138
138139## Attributes on match arms
139140
You can’t perform that action at this time.
0 commit comments