about summary refs log tree commit diff
path: root/src/libcore/iter
AgeCommit message (Collapse)AuthorLines
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
2019-01-15Rollup merge of #57608 - timvisee:master, r=frewsxcvMazdak Farrokhzad-1/+1
Simplify 'product' factorial example This simplifies the [`factorial(n: 32)`](https://doc.rust-lang.org/std/iter/trait.Iterator.html#examples-46) implementation as example for the `Iterator::product()` function. It currently uses unnecessary additional complexity. Although very minimal, I do not want to include it in some other irrelevant PR.
2019-01-15Rollup merge of #57579 - stjepang:once-with, r=SimonSapinMazdak Farrokhzad-0/+115
Add core::iter::once_with() Functions `iter::once()` and `iter::repeat()` construct iterators from values. The latter has the lazy variant `iter::repeat_with()`, but the former doesn't. This PR therefore adds `iter::once_with()`. Another way to think of `iter::once_with()` is that it's a function that converts `FnOnce() -> T` into `Iterator<Item = T>`. If this seems like a reasonable addition, I'll open a tracking issue and update the `#[feature(...)]` attributes.
2019-01-14Simplify 'product' factorial exampletimvisee-1/+1
2019-01-14Add another feature(iter_once_with)Stjepan Glavina-0/+2
2019-01-14Add feature(iter_once_with)Stjepan Glavina-0/+2
2019-01-13Fix intradoc link and update issue numberStjepan Glavina-8/+9
2019-01-13Add core::iter::once_withStjepan Glavina-0/+110
2019-01-13Change #[must_use] message of Iterator in documentationTaiki Endo-1/+1
2019-01-13Change #[must_use] message of IteratorTaiki Endo-22/+22
2019-01-13Add #[must_use] message to Iterator and FutureTaiki Endo-1/+1
2018-12-26Auto merge of #56534 - xfix:copied, r=@SimonSapinbors-1/+130
Add unstable Iterator::copied() Initially suggested at https://github.com/bluss/rust-itertools/pull/289, however the maintainers of itertools suggested this may be better of in a standard library. The intent of `copied` is to avoid accidentally cloning iterator elements after doing a code refactoring which causes a structure to be no longer `Copy`. This is a relatively common pattern, as it can be seen by calling `rg --pcre2 '[.]map[(][|](?:(\w+)[|] [*]\1|&(\w+)[|] \2)[)]'` on Rust main repository. Additionally, many uses of `cloned` actually want to simply `Copy`, and changing something to be no longer copyable may introduce unnoticeable performance penalty. Also, this makes sense because the standard library includes `[T].copy_from_slice` to pair with `[T].clone_from_slice`. This also adds `Option::copied`, because it makes sense to pair it with `Iterator::copied`. I don't think this feature is particularly important, but it makes sense to update `Option` along with `Iterator` for consistency.
2018-12-26Add a tracking issue for Iterator::copiedKonrad Borowski-7/+7
2018-12-25Remove licensesMark Rousskov-49/+0
2018-12-24Rollup merge of #56242 - GuillaumeGomez:iterator-missing-link, r=CentrilMazdak Farrokhzad-1/+1
Add missing link in docs r? @steveklabnik
2018-12-23Merge branch 'master' into copiedKonrad Borowski-32/+103
2018-12-20Add DoubleEndedIterator::nth_backClar Fon-6/+79