#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum ConstraintType {
#[default]
SumToZero,
None,
}
#[derive(Debug, Clone)]
pub struct SectorConstraint {
pub constraint_type: ConstraintType,
}
impl SectorConstraint {
#[must_use]
pub const fn sum_to_zero() -> Self {
Self { constraint_type: ConstraintType::SumToZero }
}
#[must_use]
pub const fn none() -> Self {
Self { constraint_type: ConstraintType::None }
}
#[must_use]
pub const fn is_constrained(&self) -> bool {
matches!(self.constraint_type, ConstraintType::SumToZero)
}
}
impl Default for SectorConstraint {
fn default() -> Self {
Self::sum_to_zero()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn constraint_type_default() {
let ct = ConstraintType::default();
assert_eq!(ct, ConstraintType::SumToZero);
}
#[test]
fn sector_constraint_is_constrained() {
let c = SectorConstraint::sum_to_zero();
assert!(c.is_constrained());
let c = SectorConstraint::none();
assert!(!c.is_constrained());
}
}