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. `[..]`) reads the length from the wide pointer and captures the pointer's place by `ImmBorrow`.
370
377
371
378
```rust,compile_fail,E0502
@@ -392,7 +399,7 @@ x; // OK: `x` can be moved here.
0 commit comments