Function pre_empty_fallback_chain

Source
pub fn pre_empty_fallback_chain<A: IntoIterator, B: IntoIterator<Item = A::Item>>(
    a: Option<A>,
    b: Option<B>,
) -> EmptyFallbackChain<A::IntoIter, B::IntoIter> 
Expand description

Create an EmptyFallbackChain with (optionally) one or more of the iterators set to “empty” pre-emptively, by providing it as None.

This is useful when creating conditional combinators as it prevents nested iterator type explosion, and the associated indirection.

See also: IteratorExt::maybe_empty_fallback_chain

use empty_fallback_chain as efc;

let o = efc::pre_empty_fallback_chain::<core::iter::Empty<usize>, _>(
    None,
    Some([3, 4, 5].into_iter())
).collect::<Vec<usize>>();
assert_eq!(o, vec![3, 4, 5]);