1pub mod cond;
2
3use std::cmp::{PartialEq, PartialOrd};
4use std::fmt::Debug;
5
6#[derive(Debug, Eq, PartialEq)]
7pub enum ExpressionError {
8 DivByZero,
10 InvalidVariable,
12 InvalidOperation,
14}
15
16pub trait Expression: Debug + Clone + PartialEq {
17 type Element: Debug + Copy + Clone + PartialEq + PartialOrd;
18 fn evaluate(&self, variables: &[Self::Element]) -> Result<Self::Element, ExpressionError>;
20}
21
22pub trait Condition: Debug + Clone + PartialEq {
23 type Expr: Expression;
24 fn evaluate(
26 &self,
27 variables: &[<Self::Expr as Expression>::Element],
28 ) -> Result<bool, ExpressionError>;
29}