use std::fmt::Debug;
use dyn_clone::DynClone;
use crate::AtomicConstraint;
use crate::VariableState;
pub trait InferenceChecker<Atomic: AtomicConstraint>: Debug + DynClone {
fn check(
&self,
state: VariableState<Atomic>,
premises: &[Atomic],
consequent: Option<&Atomic>,
) -> bool;
}
#[derive(Debug)]
pub struct BoxedChecker<Atomic: AtomicConstraint>(Box<dyn InferenceChecker<Atomic>>);
impl<Atomic: AtomicConstraint> Clone for BoxedChecker<Atomic> {
fn clone(&self) -> Self {
BoxedChecker(dyn_clone::clone_box(&*self.0))
}
}
impl<Atomic: AtomicConstraint> From<Box<dyn InferenceChecker<Atomic>>> for BoxedChecker<Atomic> {
fn from(value: Box<dyn InferenceChecker<Atomic>>) -> Self {
BoxedChecker(value)
}
}
impl<Atomic: AtomicConstraint> BoxedChecker<Atomic> {
pub fn check(
&self,
variable_state: VariableState<Atomic>,
premises: &[Atomic],
consequent: Option<&Atomic>,
) -> bool {
self.0.check(variable_state, premises, consequent)
}
}