exercises

Log | Files | Refs | README

expression.rs (310B)


      1 use std::collections::HashMap;
      2 
      3 pub trait Expression {
      4     fn evaluate(&self, variables: &HashMap<String, f64>) -> Result<f64, String>;
      5     fn to_string(&self) -> String;
      6 
      7     // For debugging and visualization
      8     fn precedence(&self) -> u8 {
      9         0 // Leaf nodes have lowest precedence by default
     10     }
     11 }