Function malachite_base::options::exhaustive::exhaustive_options
source · pub fn exhaustive_options<I: Iterator>(
xs: I,
) -> Chain<Once<Option<I::Item>>, ExhaustiveSomes<I>> ⓘ
Expand description
Generates all Option
s with values from a given iterator.
None
comes first, followed by the elements of the given iterator wrapped in Some
.
The output length is xs.count()
.
§Examples
use itertools::Itertools;
use malachite_base::options::exhaustive::exhaustive_options;
assert_eq!(
exhaustive_options([1, 2, 3].iter().cloned()).collect_vec(),
&[None, Some(1), Some(2), Some(3)]
);