array_tool::iter

Trait ZipOpt

Source
pub trait ZipOpt {
    // Required method
    fn zip_option<U>(self, other: U) -> ZipOption<Self, U::IntoIter>
       where Self: Sized,
             U: IntoIterator;
}
Expand description

Zips to iterators together to the longest length via Option<(Option, Option)>

Required Methods§

Source

fn zip_option<U>(self, other: U) -> ZipOption<Self, U::IntoIter>
where Self: Sized, U: IntoIterator,

Zip to iterators to longest length via Option<(Option, Option)> results.

§Example
use array_tool::iter::ZipOpt;

let a = vec!["a","b","c", "d"];
let b = vec!["c","d"];
let mut x = a.iter().zip_option(b.iter());

assert_eq!(x.next(), Some((Some(&"a"), Some(&"c"))));
assert_eq!(x.next(), Some((Some(&"b"), Some(&"d"))));
assert_eq!(x.next(), Some((Some(&"c"), None)));
assert_eq!(x.next(), Some((Some(&"d"), None)));
assert_eq!(x.next(), None);
§Output
vec![ "a", "b", "c", "d" ]

Implementors§

Source§

impl<I: Iterator> ZipOpt for I