You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Separate sections for range/slice pattern capturing
The rules for the capturing behavior related to range patterns and
slice patterns were comingled with the rules for capturing and
discriminant reads. While these are spiritually related, they are
distinct, so let's break these apart into separate sections.
Matching against a [range pattern][patterns.range] reads the place being matched, even if the range includes all possible values of the type, and captures the place by `ImmBorrow`.
358
362
359
363
```rust,compile_fail,E0502
@@ -365,7 +369,10 @@ let _ = &mut x; // ERROR: Cannot borrow `x` as mutable.
Matching a slice against a [slice pattern][patterns.slice] other than one with only a single [rest pattern][patterns.rest] (i.e. `[..]`) is treated as a read of the length from the slice and captures the slice by `ImmBorrow`.
370
377
371
378
```rust,compile_fail,E0502
@@ -392,7 +399,7 @@ let _ = &mut *x; // OK: `*x` can be borrow here.
0 commit comments