mirror of https://github.com/helix-editor/helix
Use serde attribute to rename to lowercase
parent
7961355ba1
commit
17473b51d3
|
@ -1,12 +1,12 @@
|
||||||
use anyhow::{anyhow, Error};
|
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
use serde::de::{self, Deserialize, Deserializer};
|
use serde::Deserialize;
|
||||||
use std::{
|
use std::{
|
||||||
cmp::{max, min},
|
cmp::{max, min},
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Deserialize)]
|
||||||
|
#[serde(rename_all = "lowercase")]
|
||||||
/// UNSTABLE
|
/// UNSTABLE
|
||||||
pub enum CursorKind {
|
pub enum CursorKind {
|
||||||
/// █
|
/// █
|
||||||
|
@ -25,30 +25,6 @@ impl Default for CursorKind {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for CursorKind {
|
|
||||||
type Err = Error;
|
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
||||||
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<D>(deserializer: D) -> Result<Self, D::Error>
|
|
||||||
where
|
|
||||||
D: Deserializer<'de>,
|
|
||||||
{
|
|
||||||
let s = String::deserialize(deserializer)?;
|
|
||||||
s.parse().map_err(de::Error::custom)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct Margin {
|
pub struct Margin {
|
||||||
pub vertical: u16,
|
pub vertical: u16,
|
||||||
|
|
Loading…
Reference in New Issue