blob: 5d366f78fc5751415225cc012327c67a72db5871 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
A yield expression was used outside of the coroutine literal.
Erroneous code example:
```compile_fail,E0627
#![feature(coroutines, coroutine_trait)]
fn fake_coroutine() -> &'static str {
yield 1;
return "foo"
}
fn main() {
let mut coroutine = fake_coroutine;
}
```
The error occurs because keyword `yield` can only be used inside the coroutine
literal. This can be fixed by constructing the coroutine correctly.
```
#![feature(coroutines, coroutine_trait)]
fn main() {
let mut coroutine = || {
yield 1;
return "foo"
};
}
```
|