diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-03-13 21:39:38 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-03-13 21:40:06 +0100 |
| commit | 880b1847bd4170ce80be5781c2163ba085cdcaff (patch) | |
| tree | 3fbfdb70cb04c4922f0ec9e3f29f2c63d11d753b /src/font/variant.rs | |
| parent | cb3c263c4a67f4d361dbdb5048a1c073bd1fff96 (diff) | |
Derive `Cast` for enums
Diffstat (limited to 'src/font/variant.rs')
| -rw-r--r-- | src/font/variant.rs | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/src/font/variant.rs b/src/font/variant.rs index 4eda80ad..9391aae1 100644 --- a/src/font/variant.rs +++ b/src/font/variant.rs @@ -2,7 +2,7 @@ use std::fmt::{self, Debug, Formatter}; use serde::{Deserialize, Serialize}; -use crate::eval::{cast_from_value, cast_to_value, Value}; +use crate::eval::{cast_from_value, cast_to_value, Cast, Value}; use crate::geom::Ratio; /// Properties that distinguish a font from other fonts in the same family. @@ -32,7 +32,7 @@ impl Debug for FontVariant { /// The style of a font. #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Cast)] #[serde(rename_all = "kebab-case")] pub enum FontStyle { /// The default, typically upright style. @@ -62,24 +62,6 @@ impl Default for FontStyle { } } -cast_from_value! { - FontStyle, - /// The default, typically upright style. - "normal" => Self::Normal, - /// A cursive style with custom letterform. - "italic" => Self::Italic, - /// Just a slanted version of the normal style. - "oblique" => Self::Oblique, -} - -cast_to_value! { - v: FontStyle => Value::from(match v { - FontStyle::Normal => "normal", - FontStyle::Italic => "italic", - FontStyle::Oblique => "oblique", - }) -} - /// The weight of a font. #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] #[derive(Serialize, Deserialize)] |
