Skip to content

Add a "peekable" iterator adaptor, with a peek() method that returns the next element. #8396

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 2 commits into from

Conversation

SimonSapin
Copy link
Contributor

No description provided.

@SimonSapin
Copy link
Contributor Author

The name is unfortunately close to the existing peek_ method, but the behavior is different.

@bluss
Copy link
Member

bluss commented Aug 8, 2013

This is very useful, basically an identical adaptor is going in with the TreeMap/union/intersection iterator changes, and can be refactored to use peekable as soon as this merges.

… that copies the returned value, and thus does not freeze the iterator..
@bluss
Copy link
Member

bluss commented Aug 10, 2013

We don't strictly need .peek_clone(); it can be removed if it's contentious? extra::tremap would look great using .peek(): https://github.com/blake2-ppc/rust/commit/d33a2e658536160759992e6a32c4259fe01225ff

@thestinger
Copy link
Contributor

@blake2-ppc: I think I would rather just have peek as long as there's a way to get the same behaviour as peek_clone without hitting a borrow checking error - can you open a PR with the treemap changes included?

@bluss
Copy link
Member

bluss commented Aug 10, 2013

It's possible. .peek_clone is Something like .peek().map(|x| (**x).clone()) (just deref enough to clone the right thing)

@bluss
Copy link
Member

bluss commented Aug 10, 2013

Rebased & combined with treemap changes in the new PR. peek_clone was removed, Hope this is ok simon!

@SimonSapin
Copy link
Contributor Author

Sure @blake2-ppc , that’s fine. Closing this in favor of #8428.

@SimonSapin SimonSapin closed this Aug 10, 2013
bors added a commit that referenced this pull request Aug 12, 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.

3 participants