# Pre-RFC: CPS transform for generators

**URL:** <https://internals.rust-lang.org/t/pre-rfc-cps-transform-for-generators/7120>\
**Category:** language design\
**Created:** [March 23, 2018, 1:36am UTC](https://internals.rust-lang.org/t/pre-rfc-cps-transform-for-generators/7120 "2018-03-23T01:36:29Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![withoutboats](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/withoutboats/32/4560_2.png) [@withoutboats](https://internals.rust-lang.org/u/withoutboats)\
**Post date:** [March 27, 2018, 9:29pm UTC](https://internals.rust-lang.org/t/pre-rfc-cps-transform-for-generators/7120/13 "2018-03-27T21:29:27Z")

</div>

> [@rpjohnst](#):
>
> This is not quite true, and that’s the case where the (de)serialization becomes a problem. A single generator is a flat state machine, yes. But a generator awaiting another generator is two state machines in the same allocation- the inner generator’s state block is one of the outer generator’s “live values.”

This (the core of your motivation) seems like it ignores inlining optimizations. Inlining these generators into one generator seems like the obvious solution to this problem to me.

---

_[View the full topic](https://internals.rust-lang.org/t/pre-rfc-cps-transform-for-generators/7120)._
