-
Notifications
You must be signed in to change notification settings - Fork 183
Add a couple of examples on the generator section of the book #697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a couple of examples on the generator section of the book #697
Conversation
@@ -34,6 +34,18 @@ Of these types, only upvars and resume/yield/return are stored directly in `Gene | |||
the generator by virtue of sharing the same `GeneratorId`. It is only used when determining | |||
auto trait impls, where it is considered a 'constituent type'. | |||
|
|||
For example: | |||
|
|||
```rust |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- rust
+ rust,ignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, probably make a comment that this isn't a "real" syntax at the moment.
|
||
```rust | ||
fn gen() -> Bar { | ||
let a = yield 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clarity, let's make this 0usize
.
```rust | ||
fn gen() -> Bar { | ||
let a = yield 0; | ||
return use(a); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a fn use(_: usize) -> Bar {}
for clarity
r=me on changes and green CI @bors delegate+ |
✌️ @spastorino can now approve this pull request |
(I also just realized that @spastorino already has r+ rights) |
d0f2186
to
255db5a
Compare
@bors r=jackh726 |
📌 Commit 255db5a has been approved by |
☀️ Test successful - checks-actions |
The examples may be wrong or probably could be made better but I guess having some examples here would to better understand these concepts.