Open
Description
I think it is possible to make stack generator safe. The Co
object is not Clone
, therefore the only possibility to outlive the Gen
is to return it from the coroutine, am I right? It is even impossible to yield it. Type system can require the coroutine return the Co
object along with its return value.
pub struct Gen<'s, Y, R, F: Future> {
will be
pub struct Gen<'s, Y, R, Ret, F: Future<Output = (Co<'s, Y, R>, Ret)>> {
and
pub fn resume_with(&mut self, arg: R) -> GeneratorState<Y, F::Output> {
will be
pub fn resume_with(&mut self, arg: R) -> GeneratorState<Y, Ret> {
The user is forced to return the Co
, and they cannot clone it, so it will be the same Co
, and Ret
cannot contain one more.
Metadata
Assignees
Labels
No labels