about summary refs log tree commit diff
path: root/src/libcore/iter
AgeCommit message (Collapse)AuthorLines
2019-04-02Rollup merge of #59444 - cuviper:steps_between, r=scottmcmMazdak Farrokhzad-51/+10
Implement useful steps_between for all integers We can use `usize::try_from` to convert steps from any size of integer. This enables a meaningful `size_hint()` for larger ranges, rather than always just `(0, None)`. Now they return the true `(len, Some(len))` when it fits, otherwise `(usize::MAX, None)` for overflow.
2019-04-02Rollup merge of #59262 - timvermeulen:iterator_cmp_dedup, r=scottmcmMazdak Farrokhzad-98/+14
Remove duplicated code from Iterator::{ne, lt, le, gt, ge} This PR delegates `Iterator::ne` to `Iterator::eq` and `Iterator::{lt, le, gt, ge}` to `Iterator::partial_cmp`. Oddly enough, this change actually simplifies the generated assembly [in some cases](https://rust.godbolt.org/z/riBtNe), although I don't understand assembly well enough to see if the longer assembly is doing something clever. I also added two extremely simple benchmarks: ``` // before test iter::bench_lt ... bench: 98,404 ns/iter (+/- 21,008) test iter::bench_partial_cmp ... bench: 62,437 ns/iter (+/- 5,009) // after test iter::bench_lt ... bench: 61,757 ns/iter (+/- 8,770) test iter::bench_partial_cmp ... bench: 62,151 ns/iter (+/- 13,753) ``` I have no idea why the current `lt`/`le`/`gt`/`ge` implementations don't seem to be compiled optimally, but simply having them call `partial_cmp` seems to be an improvement. See #44729 for a previous discussion.
2019-03-29Fix OnceWith docstring.Geoffry Song-2/+2
This was incorrectly copypasta'd from RepeatWith.
2019-03-26impl TrustedLen for 128-bit ranges tooJosh Stone-2/+2
2019-03-26Implement useful steps_between for all integersJosh Stone-49/+8
We can use `usize::try_from` to convert steps from any size of integer. This enables a meaningful `size_hint()` for larger ranges, rather than always just `(0, None)`. Now they return the true `(len, Some(len))` when it fits, otherwise `(usize::MAX, None)` for overflow.
2019-03-18Simplify Iterator::{lt, gt}Tim Vermeulen-8/+2
2019-03-18Replaced self-reflective explicit types with clearer `Self` or `Self::…` ↵Vincent Esche-3/+3
in stdlib docs
2019-03-17Forward Iterator::{ne, lt, le, gt, ge} to Iterator::{eq, partial_cmp}Tim Vermeulen-96/+18
2019-03-16Rollup merge of #59185 - lukaslueg:patch-2, r=cramertjkennytm-4/+2
No old chestnuts in iter::repeat docs The current language may be amusing, yet is just imprecise and most especially difficult to understand for someone who speaks English as a foreign language.
2019-03-16Rollup merge of #59082 - alexreg:cosmetic-2-doc-comments, r=Centrilkennytm-2/+2
A few improvements to comments in user-facing crates Not too many this time, and all concern comments (almost all doc comments) in user-facing crates (libstd, libcore, liballoc). r? @steveklabnik
2019-03-14Update sources.rslukaslueg-4/+2
The current language may be amusing, yet is just imprecise and most especially difficult to understand for someone who speaks English as a foreign language.
2019-03-12Forward `max` and `min` to `max_by` and `min_by` respectivelyTim Vermeulen-4/+2
2019-03-12Fix commentTim Vermeulen-1/+1
2019-03-12Remove the projection part of select_fold1Tim Vermeulen-56/+21
2019-03-11Improvements to comments in libstd, libcore, liballoc.Alexander Regueiro-2/+2
2019-02-25Have all methods of Filter and FilterMap use internal iterationTim Vermeulen-30/+7
2019-02-23Rollup merge of #58122 - matthieu-m:range_incl_perf, r=dtolnayMazdak Farrokhzad-3/+58
RangeInclusive internal iteration performance improvement. Specialize `Iterator::try_fold` and `DoubleEndedIterator::try_rfold` to improve code generation in all internal iteration scenarios. This changes brings the performance of internal iteration with `RangeInclusive` on par with the performance of iteration with `Range`: - Single conditional jump in hot loop, - Unrolling and vectorization, - And even Closed Form substitution. Unfortunately, it only applies to internal iteration. Despite various attempts at stream-lining the implementation of `next` and `next_back`, LLVM has stubbornly refused to optimize external iteration appropriately, leaving me with a choice between: - The current implementation, for which Closed Form substitution is performed, but which uses 2 conditional jumps in the hot loop when optimization fail. - An implementation using a `is_done` boolean, which uses 1 conditional jump in the hot loop when optimization fail, allowing unrolling and vectorization, but for which Closed Form substitution fails. In the absence of any conclusive evidence as to which usecase matters most, and with no assurance that the lack of Closed Form substitution is not indicative of other optimizations being foiled, there is no way to pick one implementation over the other, and thus I defer to the statu quo as far as `next` and `next_back` are concerned.
2019-02-19Stabilize iter::from_fnSimon Sapin-6/+5
FCP: https://github.com/rust-lang/rust/issues/55977#issuecomment-463964234
2019-02-19Stabilize iter::successorsSimon Sapin-7/+8
FCP: https://github.com/rust-lang/rust/issues/58045#issuecomment-464674773
2019-02-10libs: doc commentsAlexander Regueiro-8/+8
2019-02-10tests: doc commentsAlexander Regueiro-5/+5
2019-02-09Fix exhaustion of inclusive range try_fold and try_rfoldMatthieu M-2/+12
2019-02-06Fix broken grammar in iter::from_fn() docsSebastian Dröge-4/+2
2019-02-04Remove weasel word in docs for iter's take_while()lukaslueg-2/+1
The phrase "... or some similar thing." is very vague and contributes nothing to understanding the example. Simply removed.
2019-02-03RangeInclusive internal iteration performance improvement.Matthieu M-3/+48
Specialize Iterator::try_fold and DoubleEndedIterator::try_rfold to improve code generation in all internal iteration scenarios. This changes brings the performance of internal iteration with RangeInclusive on par with the performance of iteration with Range: - Single conditional jump in hot loop, - Unrolling and vectorization, - And even Closed Form substitution. Unfortunately, it only applies to internal iteration. Despite various attempts at stream-lining the implementation of next and next_back, LLVM has stubbornly refused to optimize external iteration appropriately, leaving me with a choice between: - The current implementation, for which Closed Form substitution is performed, but which uses 2 conditional jumps in the hot loop when optimization fail. - An implementation using a "is_done" boolean, which uses 1 conditional jump in the hot loop when optimization fail, allowing unrolling and vectorization, but for which Closed Form substitution fails. In the absence of any conclusive evidence as to which usecase matters most, and with no assurance that the lack of Closed Form substitution is not indicative of other optimizations being foiled, there is no way to pick one implementation over the other, and thus I defer to the statu quo as far as next and next_back are concerned.
2019-02-03Auto merge of #57922 - davidtwco:issue-57410, r=petrochenkovbors-0/+3
Update visibility of intermediate use items. Fixes #57410 and fixes #53925 and fixes #47816. Currently, the target of a use statement will be updated with the visibility of the use statement itself (if the use statement was visible). This PR ensures that if the path to the target item is via another use statement then that intermediate use statement will also have the visibility updated like the target. This silences incorrect `unreachable_pub` lints with inactionable suggestions.
2019-02-02Update visibility of intermediate use items.David Wood-0/+3
Currently, the target of a use statement will be updated with the visibility of the use statement itself (if the use statement was visible). This commit ensures that if the path to the target item is via another use statement then that intermediate use statement will also have the visibility updated like the target. This silences incorrect `unreachable_pub` lints with inactionable suggestions.
2019-02-01Rename iter::unfold to iter::from_fn and remove explicit stateSimon Sapin-32/+25
This API is unstable. CC https://github.com/rust-lang/rust/issues/55977#issuecomment-459657195
2019-01-22Move trivial constructors to inherent methodsClar Fon-26/+76
2019-01-22Move nontrivial constructors to inherent methodsClar Fon-25/+60
2019-01-22Don't expose ZipImpl to IteratorClar Fon-5/+5
2019-01-22Move super_nth out of ZipImplClar Fon-7/+9
2019-01-22Don't expose FlattenCompat to IteratorClar Fon-13/+24
2019-01-22Don't expose ChainState to IteratorClar Fon-8/+12
2019-01-22Move Flatten and FlatMap to own moduleClar Fon-313/+321
2019-01-22Move Chain and ChainState to own moduleClar Fon-251/+258
2019-01-22Move TrustedRandomAccess into Zip moduleClar Fon-2/+19
2019-01-22Move Zip and ZipImpl to own moduleClar Fon-258/+266
2019-01-22Move FusedIterator, TrustedLen to own moduleClar Fon-45/+46
2019-01-22Move Sum, Product to own moduleClar Fon-226/+227
2019-01-22Move FromIterator, IntoIterator, Extend into own moduleClar Fon-350/+351
2019-01-22Move ExactSizeIterator to own moduleClar Fon-143/+145
2019-01-22Move DoubleEndedIterator to own moduleClar Fon-298/+300
2019-01-22Move core::iter iterator.rs to traits moduleClar Fon-8/+11
2019-01-22Move core::iter adapters to adapters.rsClar Fon-2769/+2790
2019-01-17Compare pairs with `slice::windows`Kevin Leimkuhler-1/+4
2019-01-17Improve documentation and slice implKevin Leimkuhler-2/+6
2019-01-17Add is_sorted unstable documentationKevin Leimkuhler-0/+2
2019-01-17Add is_sorted impl for [T]Kevin Leimkuhler-20/+16
2019-01-17Add initial impl of is_sorted to IteratorKevin Leimkuhler-0/+84