Function exclusive_scan

Source
pub fn exclusive_scan<T, F: Fn(T, T) -> T>(
    src: &[T],
    prev: 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 call of f is performed with the additional previous value prev, which may be thought of as appearing one position before the beginning of the input array, and the result of this call is stored in the first position of dst.

§Panics

This method panics if the slices have different lengths.

§Illustration

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