diff --git a/src/calc.rs b/src/calc.rs index c84f08f..1466fd1 100644 --- a/src/calc.rs +++ b/src/calc.rs @@ -30,9 +30,13 @@ enum HistoryMode { pub struct Calculator { #[serde(skip)] l: String, + pub stack: VecDeque, save_on_close: bool, pub calculator_alignment: CalculatorAlignment, - pub stack: VecDeque, + #[serde(flatten)] + pub angle_mode: CalculatorAngleMode, + #[serde(flatten)] + pub display_mode: CalculatorDisplayMode, #[serde(serialize_with = "ordered_char_map")] pub macros: CalculatorMacros, #[serde(skip)] @@ -47,8 +51,6 @@ pub struct Calculator { redo_buf: Vec, #[serde(skip)] pub state: CalculatorState, - pub angle_mode: CalculatorAngleMode, - pub display_mode: CalculatorDisplayMode, } fn ordered_char_map(value: &HashMap, serializer: S) -> Result diff --git a/src/calc/types.rs b/src/calc/types.rs index 7aae9a4..45a6c02 100644 --- a/src/calc/types.rs +++ b/src/calc/types.rs @@ -24,14 +24,12 @@ impl Default for CalculatorState { } #[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(tag = "constant")] pub struct CalculatorConstant { pub help: String, pub value: f64, } #[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(tag = "macro")] pub struct CalculatorMacro { pub help: String, pub value: String,