Tracking Issue for Iterator::map_windows (feature iter_map_windows) · Issue #87155 · rust-lang/rust (original) (raw)

Feature gate: #![feature(iter_map_windows)]

This is a tracking issue for Iterator::map_windows:

Calls the given function f for each contiguous window of size N over self and returns an iterator over the outputs of f.

In the following example, the closure is called three times with the arguments &['a', 'b'], &['b', 'c'] and &['c', 'd'] respectively.

#![feature(iter_map_windows)]

let strings = "abcd".chars()
   .map_windows(|[x, y]| format!("{}+{}", x, y))
   .collect::<Vec<String>>();

assert_eq!(strings, vec!["a+b", "b+c", "c+d"]);

Public API

impl Iterator { fn map_windows<F, R, const N: usize>(self, f: F) -> MapWindows<Self, F, N> where Self: Sized, F: FnMut(&[Self::Item; N]) -> R; }

struct MapWindows<I: Iterator, F, const N: usize> { ... }

impl<I, F, R, const N: usize> Iterator for MapWindows<I, F, N> where I: Iterator, F: FnMut(&[I::Item; N]) -> R;

impl<I: Iterator + fmt::Debug, F, const N: usize> fmt::Debug for MapWindows<I, F, N>;

Steps / History

Unresolved Questions