Skip to content

Conversation

@steveklabnik
Copy link
Contributor

An introduction to iterators. I kinda like this, but I kinda don't. Hmmm.

src/doc/guide.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/an/can/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@killercup
Copy link
Contributor

Nicely written. I expected to learn two more things though:

  • Iterators themselves are lazy
  • One can simply implement the Iterator trait by writing a next method that returns Some(next_value) as long as there is stuff to iterate and None at the end.

(Correct me if this is wrong.)

@steveklabnik
Copy link
Contributor Author

@killercup great point on the lazy, but we haven't actually introduced traits yet, so we can't talk about that. Implementing iterators is out of the scope of this guide, but should certainly go in the broader iterator documentation.

@steveklabnik
Copy link
Contributor Author

Okay. New draft up. This is significantly different, but addresses all of the problems with the last one. What do we think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the int in Some(int) meant to be the type or meant to be a name binding?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the type.

@huonw
Copy link
Contributor

huonw commented Aug 13, 2014

I like it!

src/doc/guide.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing ). Also, looking at it written down, maybe it could be just fold(base, |accumulator, element| ...).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed.

src/doc/guide.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be precise, they're not always new as it repeats after 264 (or 232) elements.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a sentence here. Once we address #15526 , I'll make it more specific.

bors added a commit that referenced this pull request Aug 20, 2014
An introduction to iterators. I kinda like this, but I kinda don't. Hmmm.
@bors bors closed this Aug 20, 2014
@bors bors merged commit baf305d into rust-lang:master Aug 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants