From 17473b51d37001d4966b82d83d61d3e695e8403d Mon Sep 17 00:00:00 2001 From: Gokul Soumya Date: Thu, 25 Nov 2021 22:35:07 +0530 Subject: Use serde attribute to rename to lowercase --- helix-view/src/graphics.rs | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) (limited to 'helix-view/src') diff --git a/helix-view/src/graphics.rs b/helix-view/src/graphics.rs index c9dd21e3..acdaa696 100644 --- a/helix-view/src/graphics.rs +++ b/helix-view/src/graphics.rs @@ -1,12 +1,12 @@ -use anyhow::{anyhow, Error}; use bitflags::bitflags; -use serde::de::{self, Deserialize, Deserializer}; +use serde::Deserialize; use std::{ cmp::{max, min}, str::FromStr, }; -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Deserialize)] +#[serde(rename_all = "lowercase")] /// UNSTABLE pub enum CursorKind { /// █ @@ -25,30 +25,6 @@ impl Default for CursorKind { } } -impl FromStr for CursorKind { - type Err = Error; - - fn from_str(s: &str) -> Result { - match s { - "bar" => Ok(Self::Bar), - "block" => Ok(Self::Block), - "underline" => Ok(Self::Underline), - _ => Err(anyhow!("Invalid cursor '{}'", s)), - } - } -} - -// toml deserializer doesn't seem to recognize string as enum -impl<'de> Deserialize<'de> for CursorKind { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let s = String::deserialize(deserializer)?; - s.parse().map_err(de::Error::custom) - } -} - #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Margin { pub vertical: u16, -- cgit v1.2.3-70-g09d2