Skip to content

Commit 01c6c4c

Browse files
meithecattetraviscross
authored andcommitted
Clarify what gets read by slice patterns
1 parent 8660387 commit 01c6c4c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/types/closure.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ c();
340340
```
341341

342342
r[type.closure.capture.precision.discriminants.slice-patterns]
343-
Matching against a [slice pattern][patterns.slice] performs a read if the slice pattern needs to inspect the length of the scrutinee. The read will cause the closure to borrow the relevant place by `ImmBorrow`.
343+
Matching against a [slice pattern][patterns.slice] that needs to inspect the length of the scrutinee performs a read of the pointer value in order to fetch the length. The read will cause the closure to borrow the relevant place by `ImmBorrow`.
344344

345345
```rust,compile_fail,E0506
346346
let x: &mut [i32] = &mut [1, 2, 3];
@@ -352,7 +352,7 @@ x[0] += 1; // ERROR: cannot assign to `x[_]` because it is borrowed
352352
c();
353353
```
354354

355-
As such, matching against an array doesn't itself cause any borrows, as the lengthh is fixed and doesn't need to be read.
355+
As such, matching against an array doesn't itself cause any borrows, as the lengthh is fixed and the pattern doesn't need to inspect it.
356356

357357
```rust
358358
let mut x: [i32; 3] = [1, 2, 3];

0 commit comments

Comments
 (0)