@@ -1,12 +1,12 @@
1−use anyhow::{anyhow, Error};
21use bitflags::bitflags;
3−use serde::de::{self, Deserialize, Deserializer};
2+use serde::Deserialize;
43use std::{
54 cmp::{max, min},
65 str::FromStr,
76};
87
9−#[derive(Debug, Clone, Copy, PartialEq)]
8+#[derive(Debug, Clone, Copy, PartialEq, Deserialize)]
9+#[serde(rename_all = "lowercase")]
1010/// UNSTABLE
1111pub enum CursorKind {
1212 /// █
@@ -25,30 +25,6 @@ impl Default for CursorKind {
2525 }
2626}
2727
28−impl FromStr for CursorKind {
29− type Err = Error;
30−
31− fn from_str(s: &str) -> Result<Self, Self::Err> {
32− match s {
33− "bar" => Ok(Self::Bar),
34− "block" => Ok(Self::Block),
35− "underline" => Ok(Self::Underline),
36− _ => Err(anyhow!("Invalid cursor '{}'", s)),
37− }
38− }
39−}
40−
41−// toml deserializer doesn't seem to recognize string as enum
42−impl<'de> Deserialize<'de> for CursorKind {
43− fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
44− where
45− D: Deserializer<'de>,
46− {
47− let s = String::deserialize(deserializer)?;
48− s.parse().map_err(de::Error::custom)
49− }
50−}
51−
5228#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5329pub struct Margin {
5430 pub vertical: u16,