Function inclusive_scan

Source
pub fn inclusive_scan<T, F: Fn(T, T) -> T>(src: &[T], f: F, dst: &mut [T])
where T: Copy,
Expand description

Apply the closure f to each neighbouring pair of elements in src, storing the result in dst. The first element is copied as-is, and the first result of calling f on the first two elements of src in stored in the second position of dst.

§Panics

This method panics if the slices have different lengths.

§Illustration

    +--------+--------+--------+---
src |   a    |   b    |   c    | ...
    +--------+--------+--------+---
        |  \   /    \   /    \   /
        |   \ /      \ /      \ /
        |    f        f        f
        |     \        \        \
        |      \        \        \
    +--------+--------+--------+---
dst |   a    | f(a,b) | f(b,c) | ...
    +--------+--------+--------+---