1use super::math_node::NodeIndex;
2use super::numbers::{NumType, Number};
3use std::fmt;
4
5#[derive(Default, Debug, Clone)]
6pub struct Cn {
7 pub r#type: Option<NumType>,
8 pub value: Option<Number>,
9 pub parent: Option<NodeIndex>,
10}
11
12impl fmt::Display for Cn {
13 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
14 match &self.value {
15 Some(Number::Integer(i)) => write!(f, "integer: {}", i),
16 Some(Number::Real(r)) => write!(f, "real: {}", r),
17 Some(Number::Rational(n, d)) => write!(f, "rational: {} / {}", n, d),
18 Some(Number::ComplexPolar(a, b)) | Some(Number::ComplexCartesian(a, b)) => {
19 write!(f, "complex: {}, {}", a, b)
20 }
21 Some(Number::Constant(s)) => write!(f, "complex: {}", s),
22 Some(Number::ENotation(a, b)) => write!(f, "exp: {} ^ {}", a, b),
23 None => write!(f, "type is None"),
24 }
25 }
26}
27
28