use crate::elements::Element; use crate::utils::Boxed; #[derive(Debug, Clone, PartialOrd, PartialEq)] pub struct Expression { pub children: Vec, } #[derive(Debug, Clone, PartialOrd, PartialEq)] pub enum Special { Sum(Sum), Prod(Prod), Frac(Frac), Pow(Pow), Sub(Sub), Sqrt(Sqrt), Root(Root), Integral(Integral), OIntegral(OIntegral), } #[derive(Debug, Clone, PartialOrd, PartialEq)] pub struct Sum { pub top: Option>, pub bottom: Option>, } #[derive(Debug, Clone, PartialOrd, PartialEq)] pub struct Prod { pub top: Option>, pub bottom: Option>, } #[derive(Debug, Clone, PartialOrd, PartialEq)] pub struct Frac { pub(crate) top: Box, pub(crate) bottom: Box, } #[derive(Debug, Clone, PartialOrd, PartialEq)] pub struct Pow { pub(crate) base: Box, pub(crate) exp: Box, } #[derive(Debug, Clone, PartialOrd, PartialEq)] pub struct Sub { pub(crate) base: Box, pub(crate) lower: Box, } #[derive(Debug, Clone, PartialOrd, PartialEq)] pub struct Sqrt { pub(crate) inner: Box, } #[derive(Debug, Clone, PartialOrd, PartialEq)] pub struct Root { pub(crate) base: Box, pub(crate) inner: Box, } #[derive(Debug, Clone, PartialOrd, PartialEq)] pub struct Integral { pub(crate) top: Option>, pub(crate) bottom: Option>, } #[derive(Debug, Clone, PartialOrd, PartialEq)] pub struct OIntegral { pub(crate) top: Option>, pub(crate) bottom: Option>, } impl Expression { pub fn new() -> Self { Self { children: Vec::new(), } } pub fn add_child(&mut self, child: Element) { self.children.push(child) } } impl Boxed for Expression {} impl Sum { pub fn new() -> Self { Self { bottom: None, top: None, } } } impl Prod { pub fn new() -> Self { Self { bottom: None, top: None, } } }