Skip to content

Implement .cycle() for clonable iterators and impl Clone for some iterators #7882

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

Closed
wants to merge 5 commits into from
Closed

Conversation

bluss
Copy link
Member

@bluss bluss commented Jul 18, 2013

Implement method .cycle() that repeats an iterator endlessly

Implement Clone for simple iterators (without closures), including VecIterator.

The theory is simple, the immutable iterators simply hold state
variables (indicies or pointers) into frozen containers. We can freely
clone these iterators, just like we can clone borrowed pointers.

@bluss
Copy link
Member Author

bluss commented Jul 18, 2013

Fixed the problem in VecIterator::clone that thestinger pointed out.

@bluss
Copy link
Member Author

bluss commented Jul 18, 2013

thanks

blake2-ppc added 5 commits July 20, 2013 20:22
The theory is simple, the immutable iterators simply hold state
variables (indicies or pointers) into frozen containers. We can freely
clone these iterators, just like we can clone borrowed pointers.

VecIterator needs a manual impl to handle the lifetime struct member.
@bluss
Copy link
Member Author

bluss commented Jul 20, 2013

Rebased to resolve the merge conflict (in iterator.rs, the commit adding the test).

Also wrote the VecIterator clone impl much simpler. It's implicitly copyable, so just do *self.

bors added a commit that referenced this pull request Jul 20, 2013
Implement method .cycle() that repeats an iterator endlessly

Implement Clone for simple iterators (without closures), including VecIterator.

> The theory is simple, the immutable iterators simply hold state
> variables (indicies or pointers) into frozen containers. We can freely
> clone these iterators, just like we can clone borrowed pointers.
@bors bors closed this Jul 21, 2013
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.

2 participants