Skip to content

Commit 9f6497c

Browse files
Fix enum representation of future
`g: MutexGuard<'_, u32>` does not exist in the scope of the "unresumed" generator / future, so this fixes it. On top of that, I have taken the freedom to add a the `Return` variant to the enum, and have also added some comments on top of it, in order to have a precise recap' of the cited post about generators.
1 parent 8713f96 commit 9f6497c

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

posts/inside-rust/2019-10-11-AsyncAwait-Not-Send-Error-Improvements.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,25 @@ async fn bar(x: &Mutex<u32>) {
121121
```
122122

123123
```rust
124-
enum BarGenerator {
125-
Unresumed { x: &Mutex<u32>, g: MutexGuard<'_, u32>, },
126-
Suspend0 { x: &Mutex<u32>, g: MutexGuard<'_, u32>, }
124+
enum BarAsyncFnGenerator {
125+
Unresumed {
126+
// async fn params
127+
x: &Mutex<u32>,
128+
},
129+
130+
Suspend0 {
131+
// future being polled: baz_fut = baz()
132+
baz_fut: BazAsyncFnGenerator,
133+
134+
// locals that cross the await point
135+
x: &Mutex<u32>,
136+
g: MutexGuard<'_, u32>,
137+
},
138+
139+
Return(
140+
// value returned by the future
141+
()
142+
)
127143
}
128144
```
129145

0 commit comments

Comments
 (0)