#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub(crate) enum Partitioning {
#[default]
Single,
#[allow(dead_code)]
Arbitrary(usize),
}
impl Partitioning {
pub(crate) fn count(&self) -> usize {
match self {
Self::Single => 1,
Self::Arbitrary(n) => *n,
}
}
pub(crate) fn is_single(&self) -> bool {
self.count() <= 1
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn single_is_the_default() {
assert_eq!(Partitioning::default(), Partitioning::Single);
}
#[test]
fn count_reports_the_number_of_streams() {
assert_eq!(Partitioning::Single.count(), 1);
assert_eq!(Partitioning::Arbitrary(8).count(), 8);
}
#[test]
fn a_degenerate_split_still_counts_as_single() {
assert!(Partitioning::Arbitrary(1).is_single());
assert!(!Partitioning::Arbitrary(2).is_single());
}
}