malachite_base/bools/exhaustive.rs
1// Copyright © 2025 Mikhail Hogrefe
2//
3// This file is part of Malachite.
4//
5// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU
6// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version
7// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.
8
9use core::iter::Copied;
10use core::slice::Iter;
11
12/// An iterator that generates both [`bool`]s.
13///
14/// This `struct` is created by [`exhaustive_bools`]; see its documentation for more.
15pub type ExhaustiveBools = Copied<Iter<'static, bool>>;
16
17/// Generates both [`bool`]s.
18///
19/// The output length is 2.
20///
21/// # Worst-case complexity per iteration
22/// Constant time and additional memory.
23///
24/// # Examples
25/// ```
26/// use itertools::Itertools;
27/// use malachite_base::bools::exhaustive::exhaustive_bools;
28///
29/// assert_eq!(exhaustive_bools().collect_vec(), &[false, true]);
30/// ```
31#[inline]
32pub fn exhaustive_bools() -> ExhaustiveBools {
33 [false, true].iter().copied()
34}