Function itertools::intersperse_with
source · pub fn intersperse_with<I, F>(
iterable: I,
element: F,
) -> IntersperseWith<I::IntoIter, F> ⓘ
Expand description
Iterate iterable
with a particular value created by a function inserted
between each element.
IntoIterator
enabled version of Iterator::intersperse_with
.
use itertools::intersperse_with;
let mut i = 10;
itertools::assert_equal(intersperse_with((0..3), || { i -= 1; i }), vec![0, 9, 1, 8, 2]);
assert_eq!(i, 8);