Continue work on separating complex types
This commit is contained in:
parent
c47287b4e6
commit
dab0333b31
@ -34,7 +34,7 @@ impl PartialEq for Number {
|
|||||||
// pub value: Vec<Number>,
|
// pub value: Vec<Number>,
|
||||||
// }
|
// }
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Debug, Serialize, Deserialize)]
|
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
pub enum Entry {
|
pub enum Entry {
|
||||||
Number(Number),
|
Number(Number),
|
||||||
@ -175,9 +175,15 @@ impl CalculatorEntry for Number {
|
|||||||
fn format_entry(&self, display_mode: &CalculatorDisplayMode) -> String {
|
fn format_entry(&self, display_mode: &CalculatorDisplayMode) -> String {
|
||||||
match display_mode {
|
match display_mode {
|
||||||
CalculatorDisplayMode::Default => format!("{}", self.value),
|
CalculatorDisplayMode::Default => format!("{}", self.value),
|
||||||
CalculatorDisplayMode::Separated { separator } => separated(self.value, *separator),
|
CalculatorDisplayMode::Separated { separator } => {
|
||||||
CalculatorDisplayMode::Scientific { precision } => scientific(self.value, *precision),
|
separated(self.value, *separator)
|
||||||
CalculatorDisplayMode::Engineering { precision } => engineering(self.value, *precision),
|
}
|
||||||
|
CalculatorDisplayMode::Scientific { precision } => {
|
||||||
|
scientific(self.value, *precision)
|
||||||
|
}
|
||||||
|
CalculatorDisplayMode::Engineering { precision } => {
|
||||||
|
engineering(self.value, *precision)
|
||||||
|
}
|
||||||
CalculatorDisplayMode::Fixed { precision } => {
|
CalculatorDisplayMode::Fixed { precision } => {
|
||||||
format!("{:0>.precision$}", self.value, precision = precision)
|
format!("{:0>.precision$}", self.value, precision = precision)
|
||||||
}
|
}
|
||||||
@ -246,7 +252,9 @@ impl CalculatorEntry for Number {
|
|||||||
value: match angle_mode {
|
value: match angle_mode {
|
||||||
CalculatorAngleMode::Degrees => self.value.to_radians().sin(),
|
CalculatorAngleMode::Degrees => self.value.to_radians().sin(),
|
||||||
CalculatorAngleMode::Radians => self.value.sin(),
|
CalculatorAngleMode::Radians => self.value.sin(),
|
||||||
CalculatorAngleMode::Grads => (self.value * std::f64::consts::PI / 200.0).sin(),
|
CalculatorAngleMode::Grads => {
|
||||||
|
(self.value * std::f64::consts::PI / 200.0).sin()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@ -255,7 +263,9 @@ impl CalculatorEntry for Number {
|
|||||||
value: match angle_mode {
|
value: match angle_mode {
|
||||||
CalculatorAngleMode::Degrees => self.value.to_radians().cos(),
|
CalculatorAngleMode::Degrees => self.value.to_radians().cos(),
|
||||||
CalculatorAngleMode::Radians => self.value.cos(),
|
CalculatorAngleMode::Radians => self.value.cos(),
|
||||||
CalculatorAngleMode::Grads => (self.value * std::f64::consts::PI / 200.0).cos(),
|
CalculatorAngleMode::Grads => {
|
||||||
|
(self.value * std::f64::consts::PI / 200.0).cos()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@ -264,7 +274,9 @@ impl CalculatorEntry for Number {
|
|||||||
value: match angle_mode {
|
value: match angle_mode {
|
||||||
CalculatorAngleMode::Degrees => self.value.to_radians().tan(),
|
CalculatorAngleMode::Degrees => self.value.to_radians().tan(),
|
||||||
CalculatorAngleMode::Radians => self.value.tan(),
|
CalculatorAngleMode::Radians => self.value.tan(),
|
||||||
CalculatorAngleMode::Grads => (self.value * std::f64::consts::PI / 200.0).tan(),
|
CalculatorAngleMode::Grads => {
|
||||||
|
(self.value * std::f64::consts::PI / 200.0).tan()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@ -273,7 +285,9 @@ impl CalculatorEntry for Number {
|
|||||||
value: match angle_mode {
|
value: match angle_mode {
|
||||||
CalculatorAngleMode::Degrees => self.value.asin().to_degrees(),
|
CalculatorAngleMode::Degrees => self.value.asin().to_degrees(),
|
||||||
CalculatorAngleMode::Radians => self.value.asin(),
|
CalculatorAngleMode::Radians => self.value.asin(),
|
||||||
CalculatorAngleMode::Grads => self.value.asin() * std::f64::consts::PI / 200.0,
|
CalculatorAngleMode::Grads => {
|
||||||
|
self.value.asin() * std::f64::consts::PI / 200.0
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@ -282,7 +296,9 @@ impl CalculatorEntry for Number {
|
|||||||
value: match angle_mode {
|
value: match angle_mode {
|
||||||
CalculatorAngleMode::Degrees => self.value.acos().to_degrees(),
|
CalculatorAngleMode::Degrees => self.value.acos().to_degrees(),
|
||||||
CalculatorAngleMode::Radians => self.value.acos(),
|
CalculatorAngleMode::Radians => self.value.acos(),
|
||||||
CalculatorAngleMode::Grads => self.value.acos() * std::f64::consts::PI / 200.0,
|
CalculatorAngleMode::Grads => {
|
||||||
|
self.value.acos() * std::f64::consts::PI / 200.0
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@ -291,7 +307,9 @@ impl CalculatorEntry for Number {
|
|||||||
value: match angle_mode {
|
value: match angle_mode {
|
||||||
CalculatorAngleMode::Degrees => self.value.atan().to_degrees(),
|
CalculatorAngleMode::Degrees => self.value.atan().to_degrees(),
|
||||||
CalculatorAngleMode::Radians => self.value.atan(),
|
CalculatorAngleMode::Radians => self.value.atan(),
|
||||||
CalculatorAngleMode::Grads => self.value.atan() * std::f64::consts::PI / 200.0,
|
CalculatorAngleMode::Grads => {
|
||||||
|
self.value.atan() * std::f64::consts::PI / 200.0
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user