We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7b0f2af commit a0b08f3Copy full SHA for a0b08f3
src/doc/trpl/patterns.md
@@ -154,6 +154,31 @@ match x {
154
155
This prints `Got an int!`.
156
157
+If you’re using `if` with multiple patterns, the `if` applies to both sides:
158
+
159
+```rust
160
+let x = 4;
161
+let y = false;
162
163
+match x {
164
+ 4 | 5 if y => println!("yes"),
165
+ _ => println!("no"),
166
+}
167
+```
168
169
+This prints `no`, because the `if` applies to the whole of `4 | 5`, and not to
170
+just the `5`, In other words, the the precedence of `if` behaves like this:
171
172
+```text
173
+(4 | 5) if y => ...
174
175
176
+not this:
177
178
179
+4 | (5 if y) => ...
180
181
182
# ref and ref mut
183
184
If you want to get a [reference][ref], use the `ref` keyword:
0 commit comments