Skip to content
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

Specialize Vec::from_iter for vec::IntoIter #40731

Merged
merged 1 commit into from
Mar 29, 2017

Conversation

sfackler
Copy link
Member

It's fairly common to expose an API which takes an IntoIterator and
immediately collects that into a vector. It's also common to buffer
a bunch of items into a vector and then pass that into one of these
APIs. If the iterator hasn't been advanced, we can make this from_iter
simply reassemble the original Vec with no actual iteration or
reallocation.

r? @aturon

It's fairly common to expose an API which takes an `IntoIterator` and
immediately collects that into a vector. It's also common to buffer
a bunch of items into a vector and then pass that into one of these
APIs. If the iterator hasn't been advanced, we can make this `from_iter`
simply reassemble the original `Vec` with no actual iteration or
reallocation.
@aturon
Copy link
Member

aturon commented Mar 27, 2017

Very nice!

@bors: r+

@bors
Copy link
Contributor

bors commented Mar 27, 2017

📌 Commit dae66e0 has been approved by aturon

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 29, 2017
Specialize Vec::from_iter for vec::IntoIter

It's fairly common to expose an API which takes an `IntoIterator` and
immediately collects that into a vector. It's also common to buffer
a bunch of items into a vector and then pass that into one of these
APIs. If the iterator hasn't been advanced, we can make this `from_iter`
simply reassemble the original `Vec` with no actual iteration or
reallocation.

r? @aturon
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 29, 2017
Specialize Vec::from_iter for vec::IntoIter

It's fairly common to expose an API which takes an `IntoIterator` and
immediately collects that into a vector. It's also common to buffer
a bunch of items into a vector and then pass that into one of these
APIs. If the iterator hasn't been advanced, we can make this `from_iter`
simply reassemble the original `Vec` with no actual iteration or
reallocation.

r? @aturon
bors added a commit that referenced this pull request Mar 29, 2017
Rollup of 5 pull requests

- Successful merges: #40682, #40731, #40783, #40838, #40864
- Failed merges:
@bors bors merged commit dae66e0 into rust-lang:master Mar 29, 2017
@sfackler sfackler deleted the vec-from-iter-spec branch November 29, 2017 23:06
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