error yield-outside-stream
`yield` допустим только в функции с результатом `stream<T, E>`.
What it means#
A generator is a function whose result type is stream<T, E> and whose body contains yield (§10.3). yield x hands the
element x (a T) to the consumer of the stream and suspends the body until the consumer asks for the next one. Anywhere
else — in an ordinary function, in a lambda inside a generator (a lambda is a different function), or in a function whose
result is not a stream — there is no stream to yield to.
Example#
fn plain() -> i32 {
yield 1 // <- yield-outside-stream
2
}error
yield-outside-stream
How to fix#
Declare the function as a generator, or return the value:
fn numbers() -> stream<i32> {
yield 1
yield 2
}