about summary refs log tree commit diff
path: root/library/core/src/iter/adapters
AgeCommit message (Collapse)AuthorLines
2025-09-26Update CURRENT_RUSTC_VERSION post-bumpMark Rousskov-2/+2
2025-09-16Fix other uses of "adaptor"Joe Birr-Pixton-1/+1
2025-09-04Rollup merge of #146136 - ↵Stuart Cook-0/+1
AudaciousAxiom:docs/missing-closing-code-block-fences, r=tgross35 docs(std): add missing closing code block fences in doc comments This PR adds a few closing code block fences which I believe are missing in some doc comments. It seems that rustdoc just autocloses code blocks at the end of doc comments and thus these were easily overlooked: I do not think these code blocks are special in any way. I found these when working on a Clippy lint that checks the last sentence of doc comments for terminal punctuation, and these were failing cases when testing against the std. Therefore I am not entirely sure these are all such cases, but still have high hopes that they are (or at least a well-defined subset of them).
2025-09-04Rollup merge of #143725 - kennytm:peekable_next_if_map, r=jhprattStuart Cook-0/+102
core: add Peekable::next_if_map Implementation for rust-lang/rust#143702
2025-09-02docs(std): add missing closing code block fences in doc commentsAudaciousAxiom-0/+1
2025-08-15Rollup merge of #144963 - rossmacarthur-forks:stabilize-core-iter-chain, ↵Jacob Pratt-4/+2
r=jhpratt Stabilize `core::iter::chain` Closes rust-lang/rust#125964
2025-08-12Add cast_init and cast_uninit methods for pointersltdk-1/+1
2025-08-05Stabilize `core::iter::chain`Ross MacArthur-4/+2
2025-07-23add Rev::into_innerJeremy Smart-0/+19
2025-07-19Rollup merge of #141076 - the8472:fix-zip-panic-safety2, r=workingjubileeMatthias Krüger-41/+33
fix Zip unsoundness (again) Some history: The Zip TrustedRandomAccess specialization has tried to emulate the side-effects of the naive implementation for a long time, including backwards iteration. #82292 tried to fix unsoundness (#82291) in that side-effect-preservation code, but this introduced some panic-safety unsoundness (#86443), but the fix #86452 didn't fix it for nested Zip iterators (#137255). Rather than piling yet another fix ontop of this heap of fixes this PR reduces the number of cases in which side-effects will be preserved; the necessary API guarantee change was approved in #83791 but we haven't made use of that so far. fixes #137255
2025-07-10core: add Peekable::next_if_mapkennytm-0/+102
2025-06-26Rollup merge of #142549 - the8472:intersperse-fold-tweak, r=tgross35Michael Goulet-1/+10
small iter.intersperse.fold() optimization No need to call into fold when the first item is already None, this avoids some redundant work for empty iterators. "But it uses Fuse" one might want to protest, but Fuse is specialized and may call into the inner iterator anyway.
2025-06-18Fix `core::iter::Fuse`'s `Default` impl to do what it's docs say it does.Zachary S-1/+23
Add a doctest with a non-empty-by-default iterator.
2025-06-15small iter.intersperse.fold() optimizationThe 8472-1/+10
No need to call into fold when the first item is already None, this avoids some redundant work for empty iterators. "But it uses Fuse" one might want to protest, but Fuse is specialized and may call into the inner iterator anyway.
2025-06-05fix Zip unsoundness (again)The 8472-41/+33
Some history: The Zip TrustedRandomAccess specialization has tried to emulate the side-effects of the naive implementation for a long time, including backwards iteration. 82292¹ tried to fix unsoundness (82291¹) in that side-effect-preservation code, but this introduced some panic-safety unsoundness (86443¹), but the fix 86452¹ didn't fix it for nested Zip iterators (137255¹). Rather than piling yet another fix ontop of this heap of fixes this PR reduces the number of cases in which side-effects will be preserved; the necessary API guarantee change was approved in 83791¹ but we haven't made use of that so far. ¹ see merge commit for linkfied issues.
2025-05-04Revert "Avoid unused clones in Cloned<I> and Copied<I>"The 8472-163/+20
This reverts commit ed5f31ab01d41a01b7206eafdf97b458dc41141a.
2025-04-27Rollup merge of #139090 - yotamofek:pr/peekable-next-if-docs, r=tgross35Matthias Krüger-3/+3
fix docs for `Peekable::next_if{_eq}` These seem like copy-paste errors (except `saves the value of` 👉 `retains` which just sounds better to me)
2025-04-19added doctest for Enumerate::next_indexJonathan Gruner-0/+21
2025-04-19add next_index to EnumerateJonathan Gruner-0/+12
2025-04-13Avoid unused clones in Cloned<I> and Copied<I>Thalia Archibald-20/+163
Avoid cloning in `Cloned<I>` or copying in `Copied<I>` when elements are only needed by reference or not at all. There is already some precedent for this, given that `__iterator_get_unchecked` is implemented, which can skip elements. The reduced clones are technically observable by a user impl of `Clone`.
2025-04-06doc changesizarma-1/+1
2025-03-28fix docs for `Peekable::next_if{_eq}`Yotam Ofek-3/+3
2025-03-23Rollup merge of #136040 - mu001999-contrib:cleanup, r=Mark-SimulacrumMichael Goulet-55/+0
Remove unused trait BoundedSize Detected by #128637 The usage of this trait is removed in #135104 r? `@the8472`
2025-03-16Rollup merge of #138082 - thaliaarchi:slice-cfg-not-test, r=thomcc许杰友 Jieyou Xu (Joe)-1/+1
Remove `#[cfg(not(test))]` gates in `core` These gates are unnecessary now that unit tests for `core` are in a separate package, `coretests`, instead of in the same files as the source code. They previously prevented the two `core` versions from conflicting with each other.
2025-03-06library: Use size_of from the prelude instead of importedThalia Archibald-2/+2
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80.
2025-03-06Remove #[cfg(not(test))] gates in coreThalia Archibald-1/+1
These gates are unnecessary now that unit tests for `core` are in a separate package, `coretests`, instead of in the same files as the source code. They previously prevented the two `core` versions from conflicting with each other.
2025-02-18Fix typo in hidden internal docs of `TrustedRandomAccess`Frank Steffahn-4/+4
I typoed the coercion direction here 4 years ago; fixing it now
2025-01-25Remove unused trait BoundedSizeMu001999-55/+0
2025-01-11Add inherent versions of MaybeUninit methods for slicesltdk-3/+1
2025-01-04do not in-place-iterate over flatmap/flattenThe 8472-32/+2
The implementation is unsound when a partially consumed iterator has some elements buffered in the front/back parts and cloning the Iterator removes the capacity from the backing vec::IntoIter.
2024-10-23"innermost", "outermost", "leftmost", and "rightmost" don't need hyphensJosh Triplett-1/+1
These are all standard dictionary words and don't require hyphenation.
2024-09-25Use `&raw` in the standard libraryJosh Stone-2/+1
Since the stabilization in #127679 has reached stage0, 1.82-beta, we can start using `&raw` freely, and even the soft-deprecated `ptr::addr_of!` and `ptr::addr_of_mut!` can stop allowing the unstable feature. I intentionally did not change any documentation or tests, but the rest of those macro uses are all now using `&raw const` or `&raw mut` in the standard library.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-7/+7
2024-09-14Rollup merge of #130053 - glowcoil:next_if-docs, r=jhprattStuart Cook-2/+2
fix doc comments for Peekable::next_if(_eq) Fix references to a nonexistent `consume` function in the doc comments for `Peekable::next_if` and `Peekable::next_if_eq`.
2024-09-06fix doc comments for Peekable::next_if(_eq)glowcoil-2/+2
Fix references to a nonexistent `consume` function in the doc comments for `Peekable::next_if` and `Peekable::next_if_eq`.
2024-09-03replace placeholder versionBoxy-3/+3
2023-01-16Implement DoubleEnded and ExactSize for Take<Repeat> and Take<RepeatWith>Michal Nazarewicz-0/+57
Repeat iterator always returns the same element and behaves the same way backwards and forwards. Take iterator can trivially implement backwards iteration over Repeat inner iterator by simply doing forwards iteration. DoubleEndedIterator is not currently implemented for Take<Repeat<T>> because Repeat doesn’t implement ExactSizeIterator which is a required bound on DEI implementation for Take. Similarly, since Repeat is an infinite iterator which never stops, Take can trivially know how many elements it’s going to return. This allows implementing ExactSizeIterator on Take<Repeat<T>>. While at it, observe that ExactSizeIterator can also be implemented for Take<RepeatWhile<F>> so add that implementation too. Since in contrast to Repeat, RepeatWhile doesn’t guarante to always return the same value, DoubleEndedIterator isn’t implemented. Those changes render core::iter::repeat_n somewhat redundant. Issue: https://github.com/rust-lang/rust/issues/104434 Issue: https://github.com/rust-lang/rust/issues/104729
2024-07-29Reformat `use` declarations.Nicholas Nethercote-77/+62
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-26Fix doc nitsJohn Arundel-3/+3
Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo", per RFC1574), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits. https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
2024-07-02chore: remove duplicate wordshattizai-1/+1
2024-06-25add comments explaining optimizations for Filter::next_chunkThe 8472-1/+3
2024-06-25fix Drop items getting leaked in Filter::next_chunkThe 8472-45/+43
The optimization only makes sense for non-drop elements anyway. Use the default implementation for items that are Drop instead. It also simplifies the implementation.
2024-06-24Replace `MaybeUninit::uninit_array()` with array repeat expression.Kevin Reid-5/+6
This is possible now that inline const blocks are stable; the idea was even mentioned as an alternative when `uninit_array()` was added: <https://github.com/rust-lang/rust/pull/65580#issuecomment-544200681> > if it’s stabilized soon enough maybe it’s not worth having a > standard library method that will be replaceable with > `let buffer = [MaybeUninit::<T>::uninit(); $N];` Const array repetition and inline const blocks are now stable (in the next release), so that circumstance has come to pass, and we no longer have reason to want `uninit_array()` other than convenience. Therefore, let’s evaluate the inconvenience by not using `uninit_array()` in the standard library, before potentially deleting it entirely.
2024-06-04Add function `core::iter::chain`Ross MacArthur-2/+38
The addition of `core::iter::zip` (#82917) set a precedent for adding plain functions for iterator adaptors. Adding `chain` makes it a little easier to `chain` two iterators. ``` for (x, y) in chain(xs, ys) {} // vs. for (x, y) in xs.into_iter().chain(ys) {} ```
2024-05-08Use generic `NonZero`.Markus Reiter-5/+5
2024-04-25remove trivial boundslcnr-13/+7
2024-04-23Add diagnostic item for std::iter::EnumerateChristopher B. Speir-0/+1
2024-04-18Rollup merge of #123406 - krtab:fix_remainder_iterchunk, r=scottmcmJubilee-1/+14
Force exhaustion in iter::ArrayChunks::into_remainder Closes: #123333
2024-04-06Don't emit divide-by-zero panic paths in `StepBy::len`Scott McMurray-31/+49
I happened to notice today that there's actually two such calls emitted in the assembly: <https://rust.godbolt.org/z/1Wbbd3Ts6> Since they're impossible, hopefully telling LLVM that will also help optimizations elsewhere.
2024-04-04force exhaustion in iter::ArrayChunks::into_remainderArthur Carcano-1/+14