# \[Pre-RFC\]: Generator integration with for loops

**URL:** https://internals.rust-lang.org/t/pre-rfc-generator-integration-with-for-loops/6625
**Category:** language design
**Created:** [January 21, 2018, 10:10pm UTC](https://internals.rust-lang.org/t/pre-rfc-generator-integration-with-for-loops/6625 "2018-01-21T22:10:12Z")
**Posts on this page:** 1
**Showing post:** 11

<div class="post-metadata">

### Author: ![idanarye](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/idanarye/32/3346_2.png) [@idanarye](https://internals.rust-lang.org/u/idanarye)
#### Post date: [January 23, 2018, 11:30am UTC](https://internals.rust-lang.org/t/pre-rfc-generator-integration-with-for-loops/6625/11 "2018-01-23T11:30:23Z")

</div>

> [@canndrew](#):
>
> The Generator trait should also be extended to take a resume argument. If this happens then we need a way to pass the argument when iterating the for loop. For this we can use continue
> 
> ```
> let gen: impl Generator<Resume=u32>;
> for x in gen {
> ...
> continue 123;
> }
> 
> ```
> 
> If the generator resumes with anything other than () then the continue is mandatory at the end of every path in the for-loop body. If the generator does resume with () then we can continue to use continue with no argument, or to omit it entirely and the end of the body. This makes the usage of continue resemble the usage of break and return with regard to ().

What's wrong with the way regular way Rust returns a value from a block?

```
let gen: impl Generator<Resume=u32>;
for x in gen {
    ...
    123
}

```

---

_[View the full topic](https://internals.rust-lang.org/t/pre-rfc-generator-integration-with-for-loops/6625)._
