Function std::iter::chain

source ·
pub fn chain<A, B>(
    a: A,
    b: B,
) -> Chain<<A as IntoIterator>::IntoIter, <B as IntoIterator>::IntoIter> 
where A: IntoIterator, B: IntoIterator<Item = <A as IntoIterator>::Item>,
🔬This is a nightly-only experimental API. (iter_chain #125964)
Expand description

Converts the arguments to iterators and links them together, in a chain.

See the documentation of Iterator::chain for more.



use std::iter::chain;

let a = [1, 2, 3];
let b = [4, 5, 6];

let mut iter = chain(a, b);

assert_eq!(, Some(1));
assert_eq!(, Some(2));
assert_eq!(, Some(3));
assert_eq!(, Some(4));
assert_eq!(, Some(5));
assert_eq!(, Some(6));
assert_eq!(, None);