malachite_base/rounding_modes/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 crate::rounding_modes::{ROUNDING_MODES, RoundingMode};
10use core::iter::Copied;
11use core::slice::Iter;
12
13pub type ExhaustiveRoundingModes = Copied<Iter<'static, RoundingMode>>;
14
15/// Generates all [`RoundingMode`]s.
16///
17/// The output length is 6.
18///
19/// # Complexity per iteration
20/// Constant time and additional memory.
21///
22/// # Examples
23/// ```
24/// use itertools::Itertools;
25/// use malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;
26/// use malachite_base::rounding_modes::RoundingMode::*;
27///
28/// assert_eq!(
29/// exhaustive_rounding_modes().collect_vec(),
30/// &[Down, Up, Floor, Ceiling, Nearest, Exact,]
31/// );
32/// ```
33#[inline]
34pub fn exhaustive_rounding_modes() -> ExhaustiveRoundingModes {
35 ROUNDING_MODES.iter().copied()
36}