1
- This error occurs because a borrow in a generator persists across a
1
+ This error occurs because a borrow in a coroutine persists across a
2
2
yield point.
3
3
4
4
Erroneous code example:
5
5
6
6
``` compile_fail,E0626
7
- # #![feature(generators, generator_trait , pin)]
7
+ # #![feature(coroutines, coroutine_trait , pin)]
8
8
# use std::ops::Coroutine;
9
9
# use std::pin::Pin;
10
10
let mut b = || {
@@ -23,7 +23,7 @@ resolve the previous example by removing the borrow and just storing
23
23
the integer by value:
24
24
25
25
```
26
- # #![feature(generators, generator_trait , pin)]
26
+ # #![feature(coroutines, coroutine_trait , pin)]
27
27
# use std::ops::Coroutine;
28
28
# use std::pin::Pin;
29
29
let mut b = || {
@@ -41,7 +41,7 @@ in those cases, something like the `Rc` or `Arc` types may be useful.
41
41
This error also frequently arises with iteration:
42
42
43
43
``` compile_fail,E0626
44
- # #![feature(generators, generator_trait , pin)]
44
+ # #![feature(coroutines, coroutine_trait , pin)]
45
45
# use std::ops::Coroutine;
46
46
# use std::pin::Pin;
47
47
let mut b = || {
@@ -57,7 +57,7 @@ Such cases can sometimes be resolved by iterating "by value" (or using
57
57
` into_iter() ` ) to avoid borrowing:
58
58
59
59
```
60
- # #![feature(generators, generator_trait , pin)]
60
+ # #![feature(coroutines, coroutine_trait , pin)]
61
61
# use std::ops::Coroutine;
62
62
# use std::pin::Pin;
63
63
let mut b = || {
@@ -72,7 +72,7 @@ Pin::new(&mut b).resume(());
72
72
If taking ownership is not an option, using indices can work too:
73
73
74
74
```
75
- # #![feature(generators, generator_trait , pin)]
75
+ # #![feature(coroutines, coroutine_trait , pin)]
76
76
# use std::ops::Coroutine;
77
77
# use std::pin::Pin;
78
78
let mut b = || {
0 commit comments