Skip to content

Commit

Permalink
Make code work
Browse files Browse the repository at this point in the history
  • Loading branch information
arora-aman committed Jul 20, 2021
1 parent 72fd033 commit 880405c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/types/closure.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,16 @@ If a closure captures a field of a composite types such as structs, tuples, and
### box-mut

```rust
struct Foo { x: i32 }

fn box_mut() {
let mut s = Foo { x: 0 } ;

let px = &mut s;
let bx = Box::new(px);


let c = #[rustc_capture_analysis] move || bx.x += 10;
let c = move || bx.x += 10;
// Mutable reference to this place:
// (*(*bx)).x
// ^ ^
Expand All @@ -401,7 +403,8 @@ fn box_mut() {
}
```

```
<!-- ignore: Omit error about unterminated string literal when representing c_prime -->
```ignore
Closure mode = move
C = {
(ref mut, (*(*bx)).x)
Expand Down Expand Up @@ -434,7 +437,8 @@ fn main() {
}
```

```
<!-- ignore: Omit error about unterminated string literal when representing c_prime -->
```ignore
Closure mode = ref
C = {
(ref mut, packed)
Expand All @@ -443,7 +447,7 @@ C' = C
```

### Optimization-Edge-Case
```rust
```edition2021
struct Int(i32);
struct B<'a>(&'a i32);
Expand All @@ -459,7 +463,8 @@ fn foo<'a, 'b>(m: &'a MyStruct<'b>) -> impl FnMut() + 'static {
```

```
<!-- ignore: Omit error about unterminated string literal when reprenting c_prime -->
```ignore
Closure mode = ref
C = {
(ref mut, *m.a)
Expand Down

0 comments on commit 880405c

Please sign in to comment.