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
22yield point.
33
44Erroneous code example:
55
66``` compile_fail,E0626
7- # #![feature(generators, generator_trait , pin)]
7+ # #![feature(coroutines, coroutine_trait , pin)]
88# use std::ops::Coroutine;
99# use std::pin::Pin;
1010let mut b = || {
@@ -23,7 +23,7 @@ resolve the previous example by removing the borrow and just storing
2323the integer by value:
2424
2525```
26- # #![feature(generators, generator_trait , pin)]
26+ # #![feature(coroutines, coroutine_trait , pin)]
2727# use std::ops::Coroutine;
2828# use std::pin::Pin;
2929let mut b = || {
@@ -41,7 +41,7 @@ in those cases, something like the `Rc` or `Arc` types may be useful.
4141This error also frequently arises with iteration:
4242
4343``` compile_fail,E0626
44- # #![feature(generators, generator_trait , pin)]
44+ # #![feature(coroutines, coroutine_trait , pin)]
4545# use std::ops::Coroutine;
4646# use std::pin::Pin;
4747let mut b = || {
@@ -57,7 +57,7 @@ Such cases can sometimes be resolved by iterating "by value" (or using
5757` into_iter() ` ) to avoid borrowing:
5858
5959```
60- # #![feature(generators, generator_trait , pin)]
60+ # #![feature(coroutines, coroutine_trait , pin)]
6161# use std::ops::Coroutine;
6262# use std::pin::Pin;
6363let mut b = || {
@@ -72,7 +72,7 @@ Pin::new(&mut b).resume(());
7272If taking ownership is not an option, using indices can work too:
7373
7474```
75- # #![feature(generators, generator_trait , pin)]
75+ # #![feature(coroutines, coroutine_trait , pin)]
7676# use std::ops::Coroutine;
7777# use std::pin::Pin;
7878let mut b = || {
0 commit comments