Improve config file format

This commit is contained in:
Austen Adler 2021-05-25 00:10:39 -04:00
parent 3e2043729a
commit 43c3dfd0f9
2 changed files with 5 additions and 5 deletions

View File

@ -30,9 +30,13 @@ enum HistoryMode {
pub struct Calculator { pub struct Calculator {
#[serde(skip)] #[serde(skip)]
l: String, l: String,
pub stack: VecDeque<f64>,
save_on_close: bool, save_on_close: bool,
pub calculator_alignment: CalculatorAlignment, pub calculator_alignment: CalculatorAlignment,
pub stack: VecDeque<f64>, #[serde(flatten)]
pub angle_mode: CalculatorAngleMode,
#[serde(flatten)]
pub display_mode: CalculatorDisplayMode,
#[serde(serialize_with = "ordered_char_map")] #[serde(serialize_with = "ordered_char_map")]
pub macros: CalculatorMacros, pub macros: CalculatorMacros,
#[serde(skip)] #[serde(skip)]
@ -47,8 +51,6 @@ pub struct Calculator {
redo_buf: Vec<CalculatorStateChange>, redo_buf: Vec<CalculatorStateChange>,
#[serde(skip)] #[serde(skip)]
pub state: CalculatorState, pub state: CalculatorState,
pub angle_mode: CalculatorAngleMode,
pub display_mode: CalculatorDisplayMode,
} }
fn ordered_char_map<S, T>(value: &HashMap<char, T>, serializer: S) -> Result<S::Ok, S::Error> fn ordered_char_map<S, T>(value: &HashMap<char, T>, serializer: S) -> Result<S::Ok, S::Error>

View File

@ -24,14 +24,12 @@ impl Default for CalculatorState {
} }
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "constant")]
pub struct CalculatorConstant { pub struct CalculatorConstant {
pub help: String, pub help: String,
pub value: f64, pub value: f64,
} }
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "macro")]
pub struct CalculatorMacro { pub struct CalculatorMacro {
pub help: String, pub help: String,
pub value: String, pub value: String,