From 43c3dfd0f911a9ad0fbc353eaa1b9214b6c33344 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Tue, 25 May 2021 00:10:39 -0400 Subject: [PATCH] Improve config file format --- src/calc.rs | 8 +++++--- src/calc/types.rs | 2 -- 2 files changed, 5 insertions(+), 5 deletions(-) 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,