Function itertools::chain

source ·
pub fn chain<I, J>(
    i: I,
    j: J
) -> Chain<<I as IntoIterator>::IntoIter, <J as IntoIterator>::IntoIter>where
    I: IntoIterator,
    J: IntoIterator<Item = I::Item>,
Expand description

Takes two iterables and creates a new iterator over both in sequence.

IntoIterator enabled version of Iterator::chain.

Example

use itertools::chain;

let mut result:Vec<i32> = Vec::new();

for element in chain(&[1, 2, 3], &[4]) {
    result.push(*element);
}
assert_eq!(result, vec![1, 2, 3, 4]);