Fixed silly custom settings parsing

This commit is contained in:
Mikayla Maki 2023-04-20 17:33:06 -07:00
parent f54ab73b47
commit c72b70d4ae

View file

@ -263,44 +263,13 @@ pub struct TerminalSettings {
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, Default)]
#[serde(rename_all = "snake_case")]
#[serde(untagged)]
pub enum TerminalLineHeight {
#[default]
#[serde(deserialize_with = "comfortable")]
Comfortable,
#[serde(deserialize_with = "standard")]
Standard,
Custom(f32),
}
// Copied from: https://github.com/serde-rs/serde/issues/1158#issuecomment-365362959
fn comfortable<'de, D>(deserializer: D) -> Result<(), D::Error>
where
D: Deserializer<'de>,
{
#[derive(Deserialize)]
enum Helper {
#[serde(rename = "comfortable")]
Variant,
}
Helper::deserialize(deserializer)?;
Ok(())
}
// Copied from: https://github.com/serde-rs/serde/issues/1158#issuecomment-365362959
fn standard<'de, D>(deserializer: D) -> Result<(), D::Error>
where
D: Deserializer<'de>,
{
#[derive(Deserialize)]
enum Helper {
#[serde(rename = "standard")]
Variant,
}
Helper::deserialize(deserializer)?;
Ok(())
}
impl TerminalLineHeight {
fn value(&self) -> f32 {
match self {