Skip to content

Commit d205033

Browse files
committed
Minor commits
1 parent b891366 commit d205033

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/types/closure.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ If a closure captures a field of a composite types such as structs, tuples, and
317317
* Input:
318318
* Analyzing the closure C yields a mapping of `Place -> Mode` that are accessed
319319
* Access mode is `ref`, `ref uniq`, `ref mut`, or `by-value` (ordered least to max)
320-
* For a `Place` that is used in two different acess modes within the same closure, the mode reported from closure analysis is the maximum access mode.
320+
* For a `Place` that is used in two different access modes within the same closure, the mode reported from closure analysis is the maximum access mode.
321321
* Note: `ByValue` use of a `Copy` type is seen as a `ref` access mode.
322322
* Closure mode is `ref` or `move`
323323
* Output:
@@ -383,6 +383,8 @@ If a closure captures a field of a composite types such as structs, tuples, and
383383

384384
### box-mut
385385

386+
This test shows how a `move` closure can sometimes capture values by mutable reference, if they are reached via a `&mut` reference.
387+
386388
```rust
387389
struct Foo { x: i32 }
388390

@@ -446,6 +448,9 @@ C' = C
446448
```
447449

448450
### Optimization-Edge-Case
451+
452+
This test shows an interesting edge case. Normally, when we see a borrow of something behind a shared reference (`&T`), we truncate to capture the entire reference, because that is more efficient (and we can always use that reference to reach all the data it refers to). However, in the case where we are dereferencing two shared references, we have to be sure to preserve the full path, since otherwise the resulting closure could have a shorter lifetime than is necessary.
453+
449454
```edition2021
450455
struct Int(i32);
451456
struct B<'a>(&'a i32);

0 commit comments

Comments
 (0)