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

rollup of small-medium size pulls #7982

Closed
wants to merge 13 commits into from
Closed

rollup of small-medium size pulls #7982

wants to merge 13 commits into from

Conversation

thestinger
Copy link
Contributor

f0f4dcc r=huonw
25e9c4c r=graydon
a87c2d1 r=brson
16f369d r=cmr
9f05cc8 r=bstrie
e858055 r=huonw
5d80938 r=thestinger
05d03e7 r=cmr
8f86fa3 r=thestinger

@alexcrichton
Copy link
Member

I can see the need for something like this, but I'm a bit confused on the actual wording. It's called RandomAccessIterator, but nothing is being iterated over? It seems like this is simply another version of the Index trait with a size method. Morally speaking, it seems RandomAccessIterator == Index + Container, so should it possibly be renamed or derived from other names? I also can't think of a compelling use case for this, so I'm sure I'm missing something big. Is this meant to generalize something like a sorting algorithm over a container like a deque/array?

Also, cc #7766

@thestinger
Copy link
Contributor Author

@alexcrichton: The Container trait doesn't work for this because the len method is the actual length, and iterators can be larger than a uint or even infinite. The Index trait is going to be removed (#6515) so I don't want to make any more code depending on it. It needs to be replaced before it can be used for this, and it's not certain it will be usable because it will have to make assumptions about mutability to replicate the vector syntax.

Random access iterators will allow generic algorithms (like sort or binary search) to work on any random access iterator, not just containers. For example you'll be able to chain together 2 vectors and a deque and sort them as a single range of values.

@omasanori
Copy link
Contributor

There is a bikeshed: iterator vs range, right?

Although random access iterators are not really iterators IHMO, C++ has been called them iterators for a long time... (I don't think Rust must use C++ term instead of dlang term. It's just an example.)

@thestinger
Copy link
Contributor Author

@omasanori: it's not really the C++ term, languages like Python use the term iterator for what D calls an InputRange

@omasanori
Copy link
Contributor

@thestinger yes, you are right.

@dotdash
Copy link
Contributor

dotdash commented Jul 24, 2013

Fixed version of my PR that failed to test on windows: https://github.com/dotdash/rust/commits/transmute_ice

bors added a commit that referenced this pull request Jul 24, 2013
f0f4dcc r=huonw
25e9c4c r=graydon
a87c2d1 r=brson
16f369d r=cmr
9f05cc8 r=bstrie
e858055 r=huonw
5d80938 r=thestinger
05d03e7 r=cmr
8f86fa3 r=thestinger
@bors bors closed this Jul 24, 2013
@Centril Centril added the rollup A PR which is a rollup label Oct 2, 2019
flip1995 pushed a commit to flip1995/rust that referenced this pull request Nov 23, 2021
Fix `needless_collect`'s tendency to suggest code requiring multiple mutable borrows of the same value.

Fixes error specified in rust-lang#7975.

changelog: [`needless_collect`] no longer suggests removal of `collect` when removal would create code requiring mutably borrowing a value multiple times.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR which is a rollup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants