#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Formulation {
expression: String,
}
impl Formulation {
pub fn new<S: Into<String>>(expression: S) -> Self {
Self {
expression: expression.into(),
}
}
pub fn expression(&self) -> &str {
&self.expression
}
}
impl From<&str> for Formulation {
fn from(value: &str) -> Self {
Self::new(value)
}
}
impl From<String> for Formulation {
fn from(value: String) -> Self {
Self::new(value)
}
}
#[cfg(test)]
mod tests {
use super::Formulation;
#[test]
fn stores_expression() {
let f = Formulation::new("0 + prices + x1");
assert_eq!(f.expression(), "0 + prices + x1");
}
}