devela::_dep::itertools

Function intersperse

pub fn intersperse<I>(
    iterable: I,
    element: <I as IntoIterator>::Item,
) -> IntersperseWith<<I as IntoIterator>::IntoIter, IntersperseElementSimple<<<I as IntoIterator>::IntoIter as Iterator>::Item>> 
where I: IntoIterator, <I as IntoIterator>::Item: Clone,
Available on crate feature dep_itertools only.
Expand description

Iterate iterable with a particular value inserted between each element.

IntoIterator enabled version of Iterator::intersperse.

use itertools::intersperse;

itertools::assert_equal(intersperse(0..3, 8), vec![0, 8, 1, 8, 2]);