mod types;
mod node;
mod builder;
pub use types::*;
pub use node::MathNode;
pub use builder::FormulaBuilder;
use bumpalo::Bump;
pub struct Formula<'arena> {
arena: Bump,
root: Vec<MathNode<'arena>>,
display_style: bool,
}
impl<'arena> Formula<'arena> {
pub fn new() -> Self {
Self {
arena: Bump::new(),
root: Vec::new(),
display_style: true,
}
}
pub fn with_display_style(display_style: bool) -> Self {
Self {
arena: Bump::new(),
root: Vec::new(),
display_style,
}
}
#[inline]
pub fn arena(&self) -> &Bump {
&self.arena
}
#[inline]
pub fn root(&self) -> &[MathNode<'arena>] {
&self.root
}
pub fn set_root(&mut self, root: Vec<MathNode<'arena>>) {
self.root = root;
}
#[inline]
pub fn display_style(&self) -> bool {
self.display_style
}
pub fn set_display_style(&mut self, display_style: bool) {
self.display_style = display_style;
}
}
impl Default for Formula<'_> {
fn default() -> Self {
Self::new()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_formula_creation() {
let formula = Formula::new();
assert!(formula.root().is_empty());
assert!(formula.display_style());
}
}