ac3rm 0.1.0

An incremental AC-3rm propagator in Rust with dynamic assertion and retraction of constraints
Documentation
use crate::VarId;
use std::fmt;

#[derive(Debug, Clone)]
pub enum Constraint {
    Equality(VarId, VarId),   // Represents an equality constraint between two variables (e.g., x_i == x_j).
    Inequality(VarId, VarId), // Represents an inequality constraint between two variables (e.g., x_i != x_j).
    Set(VarId, i32),          // Represents a constraint that a variable must take a specific value (e.g., x_i == 5).
    Forbid(VarId, i32),       // Represents a constraint that a variable cannot take a specific value (e.g., x_i != 5).
}

impl fmt::Display for Constraint {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Constraint::Equality(var1, var2) => write!(f, "{} == {}", var1, var2),
            Constraint::Inequality(var1, var2) => write!(f, "{} != {}", var1, var2),
            Constraint::Set(var, value) => write!(f, "{} == {}", var, value),
            Constraint::Forbid(var, value) => write!(f, "{} != {}", var, value),
        }
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ConstraintId(pub usize);

impl fmt::Display for ConstraintId {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "c{}", self.0)
    }
}

#[derive(Debug, Clone)]
pub(super) struct ConstraintEntry {
    pub(super) active: bool,
    pub(super) kind: Constraint,
}