Skip to content

Commit

Permalink
Closures: fix example of desugaring
Browse files Browse the repository at this point in the history
Passing `left_top.x` into `right_bottom_x`. This invalidates the comment being made. In fact, the closure lowering doesn't have any special borrow checking rules that would allow it to have two overlapping mutable borrows.
  • Loading branch information
meithecatte authored Feb 25, 2025
1 parent 615b4ce commit dea47f4
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/types/closure.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ so that the call to `f` works as if it were:

<!-- ignore: continuation of above -->
```rust,ignore
// Note: This is not valid Rust due to the duplicate mutable borrows.
// This is only provided as an illustration.
f(Closure{ left_top: &mut rect.left_top, right_bottom_x: &mut rect.left_top.x });
f(Closure{ left_top: &mut rect.left_top, right_bottom_x: &mut rect.right_bottom.x });
```

r[type.closure.capture]
Expand Down

0 comments on commit dea47f4

Please sign in to comment.