rust/library/core/src
Guillaume Gomez 7f787e397c
Rollup merge of #94667 - frank-king:feature/iter_map_windows, r=Mark-Simulacrum
Add `Iterator::map_windows`

Tracking issue:  #87155.

This is inherited from the old PR  #82413.

Unlike #82413, this PR implements the `MapWindows` to be lazy: only when pulling from the outer iterator, `.next()` of the inner iterator will be called.

## Implementaion Steps
- [x] Implement `MapWindows` to keep the iterators' [*Laziness*](https://doc.rust-lang.org/std/iter/index.html#laziness) contract.
- [x] Fix the known bug of memory access error.
- [ ] Full specialization of iterator-related traits for `MapWindows`.
    - [x] `Iterator::size_hint`,
    - [x] ~`Iterator::count`~,
    - [x] `ExactSizeIterator` (when `I: ExactSizeIterator`),
    - [x] ~`TrustedLen` (when `I: TrustedLen`)~,
    - [x] `FusedIterator`,
    - [x] ~`Iterator::advance_by`~,
    - [x] ~`Iterator::nth`~,
    - [ ] ...
- [ ] More tests and docs.

## Unresolved Questions:
- [ ] Is there any more iterator-related traits should be specialized?
- [ ] Is the double-space buffer worth?
- [ ] Should there be `rmap_windows` or something else?
- [ ] Taking GAT for consideration, should the mapper function be `FnMut(&[I::Item; N]) -> R` or something like `FnMut(ArrayView<'_, I::Item, N>) -> R`? Where `ArrayView` is mentioned in https://github.com/rust-lang/generic-associated-types-initiative/issues/2.
    - It can save memory, only the same size as the array window is needed,
    - It is more efficient, which requires less data copies,
    - It is possibly compatible with the GATified version of `LendingIterator::windows`.
    - But it prevents the array pattern matching like `iter.map_windows(|_arr: [_; N]| ())`, unless we extend the array pattern to allow matching the `ArrayView`.
2023-08-13 21:00:44 +02:00
..
alloc Rollup merge of #107916 - reez12g:issue-107040, r=Amanieu 2023-05-30 12:57:38 +02:00
array Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
ascii Rename copying ascii::Char methods from as_ to to_ 2023-08-08 16:03:47 -07:00
async_iter use consistent terminology 2022-10-29 09:23:12 +02:00
cell Rollup merge of #109318 - joboet:better_fmt_placeholder, r=dtolnay 2023-07-31 22:51:12 +02:00
char ascii::Char-ify the escaping code 2023-05-12 19:37:02 -07:00
cmp Merge two different equality specialization traits in core 2023-03-01 14:42:06 -08:00
convert Make rustc_on_unimplemented std-agnostic 2023-06-27 18:13:24 +08:00
ffi Auto merge of #113220 - tgross35:cstr-bytes-docs, r=workingjubilee 2023-08-03 02:40:19 +00:00
fmt Rollup merge of #109318 - joboet:better_fmt_placeholder, r=dtolnay 2023-07-31 22:51:12 +02:00
future Rollup merge of #109970 - danielhenrymantilla:add-poll-fn-pin-clarifications, r=thomcc 2023-06-19 19:26:25 +02:00
hash Swap out CURRENT_RUSTC_VERSION to 1.71.0 2023-05-30 07:54:29 -04:00
intrinsics Add internal_features lint 2023-08-03 14:50:50 +02:00
iter Add Iterator::map_windows 2023-08-11 07:26:51 +08:00
macros core: Remove #[macro_export] from debug_assert_matches 2023-08-07 21:13:55 +02:00
mem Flip cfg's for bootstrap bump 2023-07-12 21:38:55 -04:00
net Link methods in From impls 2023-07-18 20:58:35 -04:00
num Partially stabilize #![feature(int_roundings)] 2023-08-12 00:12:11 -04:00
ops Make rustc_on_unimplemented std-agnostic 2023-06-27 18:13:24 +08:00
panic Change default panic handler message format. 2023-07-29 11:42:50 +02:00
prelude Revert "Remove #[alloc_error_handler] from the compiler and library" 2023-04-25 00:08:35 +02:00
ptr Tell LLVM that the negation in <*const T>::sub cannot overflow 2023-08-10 23:00:39 -07:00
slice Add a new compare_bytes intrinsic instead of calling memcmp directly 2023-08-06 15:47:40 -07:00
str Work around missing <*str>::len 2023-07-31 11:42:14 -07:00
sync Auto merge of #114034 - Amanieu:riscv-atomicbool, r=thomcc 2023-07-27 01:00:12 +00:00
task Auto merge of #96875 - SabrinaJewson:noop-waker, r=m-ou-se 2023-06-07 06:04:32 +00:00
unicode Apply changes to fix python linting errors 2023-06-16 20:56:01 -04:00
any.rs Flip cfg's for bootstrap bump 2023-07-12 21:38:55 -04:00
arch.rs move core::arch into separate file 2022-11-20 10:28:14 +01:00
ascii.rs ascii::Char-ify the escaping code 2023-05-12 19:37:02 -07:00
asserting.rs [RFC 2011] Library code 2022-05-22 07:18:32 -03:00
bool.rs core is now compilable 2023-04-16 07:20:26 +00:00
borrow.rs doc: replace wrong punctuation mark 2023-07-28 14:46:17 +02:00
cell.rs Adjust some tests for invalid_reference_casting improvements 2023-07-29 12:20:59 +02:00
clone.rs Explain more clearly why fn() -> T can't be #[derive(Clone)] 2023-07-30 18:04:38 +02:00
cmp.rs Add #[inline] to functions that are never called 2023-05-07 12:41:37 +01:00
default.rs Remove default_free_fn feature 2023-07-08 12:10:12 +09:00
error.md Change default panic handler message format. 2023-07-29 11:42:50 +02:00
error.rs Bump to latest beta 2023-03-15 08:55:22 -04:00
escape.rs Rename copying ascii::Char methods from as_ to to_ 2023-08-08 16:03:47 -07:00
hint.rs Rollup merge of #108416 - pat-nel87:Issue-107957-black_box_docs, r=jyn514 2023-04-26 01:55:49 -05:00
internal_macros.rs rm const traits in libcore 2023-04-16 06:49:27 +00:00
intrinsics.rs Add a new compare_bytes intrinsic instead of calling memcmp directly 2023-08-06 15:47:40 -07:00
lib.rs Add internal_features lint 2023-08-03 14:50:50 +02:00
marker.rs Suggest using Arc on !Send/!Sync types 2023-08-09 14:04:10 +00:00
option.rs Rollup merge of #98935 - kellerkindt:option_retain, r=Mark-Simulacrum 2023-08-07 05:29:09 +02:00
panic.rs Shorten lifetime of even more panic temporaries 2023-05-15 03:47:37 -07:00
panicking.rs Launch a non-unwinding panic for misaligned pointer deref 2023-06-16 09:20:33 -04:00
pin.rs Document Pin memory layout 2023-05-18 01:30:12 -04:00
primitive.rs
primitive_docs.rs Extend unused_must_use to cover block exprs 2023-06-15 17:59:13 +08:00
result.rs Rollup merge of #112655 - WaffleLapkin:must_use_map_or, r=workingjubilee 2023-07-30 14:25:08 +02:00
time.rs Use fmt::Alignment instead of fmt::rt::v1::Alignment. 2023-04-20 18:03:47 +02:00
tuple.rs Flip cfg's for bootstrap bump 2023-07-12 21:38:55 -04:00
unit.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00