Use Self:: for matching

This commit is contained in:
ConnorSkees 2020-01-18 19:11:19 -05:00
parent 622ca8ceef
commit 99dfcb6756
2 changed files with 322 additions and 322 deletions

View File

@ -325,154 +325,154 @@ impl TryFrom<&str> for Color {
fn try_from(string: &str) -> Result<Self, Self::Error> { fn try_from(string: &str) -> Result<Self, Self::Error> {
match string { match string {
"aliceblue" => Ok(Color::AliceBlue), "aliceblue" => Ok(Self::AliceBlue),
"antiquewhite" => Ok(Color::AntiqueWhite), "antiquewhite" => Ok(Self::AntiqueWhite),
"aqua" => Ok(Color::Aqua), "aqua" => Ok(Self::Aqua),
"aquamarine" => Ok(Color::Aquamarine), "aquamarine" => Ok(Self::Aquamarine),
"azure" => Ok(Color::Azure), "azure" => Ok(Self::Azure),
"beige" => Ok(Color::Beige), "beige" => Ok(Self::Beige),
"bisque" => Ok(Color::Bisque), "bisque" => Ok(Self::Bisque),
"black" => Ok(Color::Black), "black" => Ok(Self::Black),
"blanchedalmond" => Ok(Color::BlanchedAlmond), "blanchedalmond" => Ok(Self::BlanchedAlmond),
"blue" => Ok(Color::Blue), "blue" => Ok(Self::Blue),
"blueviolet" => Ok(Color::BlueViolet), "blueviolet" => Ok(Self::BlueViolet),
"brown" => Ok(Color::Brown), "brown" => Ok(Self::Brown),
"burlywood" => Ok(Color::BurlyWood), "burlywood" => Ok(Self::BurlyWood),
"cadetblue" => Ok(Color::CadetBlue), "cadetblue" => Ok(Self::CadetBlue),
"chartreuse" => Ok(Color::Chartreuse), "chartreuse" => Ok(Self::Chartreuse),
"chocolate" => Ok(Color::Chocolate), "chocolate" => Ok(Self::Chocolate),
"coral" => Ok(Color::Coral), "coral" => Ok(Self::Coral),
"cornflowerblue" => Ok(Color::CornflowerBlue), "cornflowerblue" => Ok(Self::CornflowerBlue),
"cornsilk" => Ok(Color::Cornsilk), "cornsilk" => Ok(Self::Cornsilk),
"crimson" => Ok(Color::Crimson), "crimson" => Ok(Self::Crimson),
"cyan" => Ok(Color::Cyan), "cyan" => Ok(Self::Cyan),
"darkblue" => Ok(Color::DarkBlue), "darkblue" => Ok(Self::DarkBlue),
"darkcyan" => Ok(Color::DarkCyan), "darkcyan" => Ok(Self::DarkCyan),
"darkgoldenrod" => Ok(Color::DarkGoldenRod), "darkgoldenrod" => Ok(Self::DarkGoldenRod),
"darkgray" => Ok(Color::DarkGray), "darkgray" => Ok(Self::DarkGray),
"darkgrey" => Ok(Color::DarkGrey), "darkgrey" => Ok(Self::DarkGrey),
"darkgreen" => Ok(Color::DarkGreen), "darkgreen" => Ok(Self::DarkGreen),
"darkkhaki" => Ok(Color::DarkKhaki), "darkkhaki" => Ok(Self::DarkKhaki),
"darkmagenta" => Ok(Color::DarkMagenta), "darkmagenta" => Ok(Self::DarkMagenta),
"darkolivegreen" => Ok(Color::DarkOliveGreen), "darkolivegreen" => Ok(Self::DarkOliveGreen),
"darkorange" => Ok(Color::DarkOrange), "darkorange" => Ok(Self::DarkOrange),
"darkorchid" => Ok(Color::DarkOrchid), "darkorchid" => Ok(Self::DarkOrchid),
"darkred" => Ok(Color::DarkRed), "darkred" => Ok(Self::DarkRed),
"darksalmon" => Ok(Color::DarkSalmon), "darksalmon" => Ok(Self::DarkSalmon),
"darkseagreen" => Ok(Color::DarkSeaGreen), "darkseagreen" => Ok(Self::DarkSeaGreen),
"darkslateblue" => Ok(Color::DarkSlateBlue), "darkslateblue" => Ok(Self::DarkSlateBlue),
"darkslategray" => Ok(Color::DarkSlateGray), "darkslategray" => Ok(Self::DarkSlateGray),
"darkslategrey" => Ok(Color::DarkSlateGrey), "darkslategrey" => Ok(Self::DarkSlateGrey),
"darkturquoise" => Ok(Color::DarkTurquoise), "darkturquoise" => Ok(Self::DarkTurquoise),
"darkviolet" => Ok(Color::DarkViolet), "darkviolet" => Ok(Self::DarkViolet),
"deeppink" => Ok(Color::DeepPink), "deeppink" => Ok(Self::DeepPink),
"deepskyblue" => Ok(Color::DeepSkyBlue), "deepskyblue" => Ok(Self::DeepSkyBlue),
"dimgray" => Ok(Color::DimGray), "dimgray" => Ok(Self::DimGray),
"dimgrey" => Ok(Color::DimGrey), "dimgrey" => Ok(Self::DimGrey),
"dodgerblue" => Ok(Color::DodgerBlue), "dodgerblue" => Ok(Self::DodgerBlue),
"firebrick" => Ok(Color::FireBrick), "firebrick" => Ok(Self::FireBrick),
"floralwhite" => Ok(Color::FloralWhite), "floralwhite" => Ok(Self::FloralWhite),
"forestgreen" => Ok(Color::ForestGreen), "forestgreen" => Ok(Self::ForestGreen),
"fuchsia" => Ok(Color::Fuchsia), "fuchsia" => Ok(Self::Fuchsia),
"gainsboro" => Ok(Color::Gainsboro), "gainsboro" => Ok(Self::Gainsboro),
"ghostwhite" => Ok(Color::GhostWhite), "ghostwhite" => Ok(Self::GhostWhite),
"gold" => Ok(Color::Gold), "gold" => Ok(Self::Gold),
"goldenrod" => Ok(Color::GoldenRod), "goldenrod" => Ok(Self::GoldenRod),
"gray" => Ok(Color::Gray), "gray" => Ok(Self::Gray),
"grey" => Ok(Color::Grey), "grey" => Ok(Self::Grey),
"green" => Ok(Color::Green), "green" => Ok(Self::Green),
"greenyellow" => Ok(Color::GreenYellow), "greenyellow" => Ok(Self::GreenYellow),
"honeydew" => Ok(Color::HoneyDew), "honeydew" => Ok(Self::HoneyDew),
"hotpink" => Ok(Color::HotPink), "hotpink" => Ok(Self::HotPink),
"indianred" => Ok(Color::IndianRed), "indianred" => Ok(Self::IndianRed),
"indigo" => Ok(Color::Indigo), "indigo" => Ok(Self::Indigo),
"ivory" => Ok(Color::Ivory), "ivory" => Ok(Self::Ivory),
"khaki" => Ok(Color::Khaki), "khaki" => Ok(Self::Khaki),
"lavender" => Ok(Color::Lavender), "lavender" => Ok(Self::Lavender),
"lavenderblush" => Ok(Color::LavenderBlush), "lavenderblush" => Ok(Self::LavenderBlush),
"lawngreen" => Ok(Color::LawnGreen), "lawngreen" => Ok(Self::LawnGreen),
"lemonchiffon" => Ok(Color::LemonChiffon), "lemonchiffon" => Ok(Self::LemonChiffon),
"lightblue" => Ok(Color::LightBlue), "lightblue" => Ok(Self::LightBlue),
"lightcoral" => Ok(Color::LightCoral), "lightcoral" => Ok(Self::LightCoral),
"lightcyan" => Ok(Color::LightCyan), "lightcyan" => Ok(Self::LightCyan),
"lightgoldenrodyellow" => Ok(Color::LightGoldenRodYellow), "lightgoldenrodyellow" => Ok(Self::LightGoldenRodYellow),
"lightgray" => Ok(Color::LightGray), "lightgray" => Ok(Self::LightGray),
"lightgrey" => Ok(Color::LightGrey), "lightgrey" => Ok(Self::LightGrey),
"lightgreen" => Ok(Color::LightGreen), "lightgreen" => Ok(Self::LightGreen),
"lightpink" => Ok(Color::LightPink), "lightpink" => Ok(Self::LightPink),
"lightsalmon" => Ok(Color::LightSalmon), "lightsalmon" => Ok(Self::LightSalmon),
"lightseagreen" => Ok(Color::LightSeaGreen), "lightseagreen" => Ok(Self::LightSeaGreen),
"lightskyblue" => Ok(Color::LightSkyBlue), "lightskyblue" => Ok(Self::LightSkyBlue),
"lightslategray" => Ok(Color::LightSlateGray), "lightslategray" => Ok(Self::LightSlateGray),
"lightslategrey" => Ok(Color::LightSlateGrey), "lightslategrey" => Ok(Self::LightSlateGrey),
"lightsteelblue" => Ok(Color::LightSteelBlue), "lightsteelblue" => Ok(Self::LightSteelBlue),
"lightyellow" => Ok(Color::LightYellow), "lightyellow" => Ok(Self::LightYellow),
"lime" => Ok(Color::Lime), "lime" => Ok(Self::Lime),
"limegreen" => Ok(Color::LimeGreen), "limegreen" => Ok(Self::LimeGreen),
"linen" => Ok(Color::Linen), "linen" => Ok(Self::Linen),
"magenta" => Ok(Color::Magenta), "magenta" => Ok(Self::Magenta),
"maroon" => Ok(Color::Maroon), "maroon" => Ok(Self::Maroon),
"mediumaquamarine" => Ok(Color::MediumAquaMarine), "mediumaquamarine" => Ok(Self::MediumAquaMarine),
"mediumblue" => Ok(Color::MediumBlue), "mediumblue" => Ok(Self::MediumBlue),
"mediumorchid" => Ok(Color::MediumOrchid), "mediumorchid" => Ok(Self::MediumOrchid),
"mediumpurple" => Ok(Color::MediumPurple), "mediumpurple" => Ok(Self::MediumPurple),
"mediumseagreen" => Ok(Color::MediumSeaGreen), "mediumseagreen" => Ok(Self::MediumSeaGreen),
"mediumslateblue" => Ok(Color::MediumSlateBlue), "mediumslateblue" => Ok(Self::MediumSlateBlue),
"mediumspringgreen" => Ok(Color::MediumSpringGreen), "mediumspringgreen" => Ok(Self::MediumSpringGreen),
"mediumturquoise" => Ok(Color::MediumTurquoise), "mediumturquoise" => Ok(Self::MediumTurquoise),
"mediumvioletred" => Ok(Color::MediumVioletRed), "mediumvioletred" => Ok(Self::MediumVioletRed),
"midnightblue" => Ok(Color::MidnightBlue), "midnightblue" => Ok(Self::MidnightBlue),
"mintcream" => Ok(Color::MintCream), "mintcream" => Ok(Self::MintCream),
"mistyrose" => Ok(Color::MistyRose), "mistyrose" => Ok(Self::MistyRose),
"moccasin" => Ok(Color::Moccasin), "moccasin" => Ok(Self::Moccasin),
"navajowhite" => Ok(Color::NavajoWhite), "navajowhite" => Ok(Self::NavajoWhite),
"navy" => Ok(Color::Navy), "navy" => Ok(Self::Navy),
"oldlace" => Ok(Color::OldLace), "oldlace" => Ok(Self::OldLace),
"olive" => Ok(Color::Olive), "olive" => Ok(Self::Olive),
"olivedrab" => Ok(Color::OliveDrab), "olivedrab" => Ok(Self::OliveDrab),
"orange" => Ok(Color::Orange), "orange" => Ok(Self::Orange),
"orangered" => Ok(Color::OrangeRed), "orangered" => Ok(Self::OrangeRed),
"orchid" => Ok(Color::Orchid), "orchid" => Ok(Self::Orchid),
"palegoldenrod" => Ok(Color::PaleGoldenRod), "palegoldenrod" => Ok(Self::PaleGoldenRod),
"palegreen" => Ok(Color::PaleGreen), "palegreen" => Ok(Self::PaleGreen),
"paleturquoise" => Ok(Color::PaleTurquoise), "paleturquoise" => Ok(Self::PaleTurquoise),
"palevioletred" => Ok(Color::PaleVioletRed), "palevioletred" => Ok(Self::PaleVioletRed),
"papayawhip" => Ok(Color::PapayaWhip), "papayawhip" => Ok(Self::PapayaWhip),
"peachpuff" => Ok(Color::PeachPuff), "peachpuff" => Ok(Self::PeachPuff),
"peru" => Ok(Color::Peru), "peru" => Ok(Self::Peru),
"pink" => Ok(Color::Pink), "pink" => Ok(Self::Pink),
"plum" => Ok(Color::Plum), "plum" => Ok(Self::Plum),
"powderblue" => Ok(Color::PowderBlue), "powderblue" => Ok(Self::PowderBlue),
"purple" => Ok(Color::Purple), "purple" => Ok(Self::Purple),
"rebeccapurple" => Ok(Color::RebeccaPurple), "rebeccapurple" => Ok(Self::RebeccaPurple),
"red" => Ok(Color::Red), "red" => Ok(Self::Red),
"rosybrown" => Ok(Color::RosyBrown), "rosybrown" => Ok(Self::RosyBrown),
"royalblue" => Ok(Color::RoyalBlue), "royalblue" => Ok(Self::RoyalBlue),
"saddlebrown" => Ok(Color::SaddleBrown), "saddlebrown" => Ok(Self::SaddleBrown),
"salmon" => Ok(Color::Salmon), "salmon" => Ok(Self::Salmon),
"sandybrown" => Ok(Color::SandyBrown), "sandybrown" => Ok(Self::SandyBrown),
"seagreen" => Ok(Color::SeaGreen), "seagreen" => Ok(Self::SeaGreen),
"seashell" => Ok(Color::SeaShell), "seashell" => Ok(Self::SeaShell),
"sienna" => Ok(Color::Sienna), "sienna" => Ok(Self::Sienna),
"silver" => Ok(Color::Silver), "silver" => Ok(Self::Silver),
"skyblue" => Ok(Color::SkyBlue), "skyblue" => Ok(Self::SkyBlue),
"slateblue" => Ok(Color::SlateBlue), "slateblue" => Ok(Self::SlateBlue),
"slategray" => Ok(Color::SlateGray), "slategray" => Ok(Self::SlateGray),
"slategrey" => Ok(Color::SlateGrey), "slategrey" => Ok(Self::SlateGrey),
"snow" => Ok(Color::Snow), "snow" => Ok(Self::Snow),
"springgreen" => Ok(Color::SpringGreen), "springgreen" => Ok(Self::SpringGreen),
"steelblue" => Ok(Color::SteelBlue), "steelblue" => Ok(Self::SteelBlue),
"tan" => Ok(Color::Tan), "tan" => Ok(Self::Tan),
"teal" => Ok(Color::Teal), "teal" => Ok(Self::Teal),
"thistle" => Ok(Color::Thistle), "thistle" => Ok(Self::Thistle),
"tomato" => Ok(Color::Tomato), "tomato" => Ok(Self::Tomato),
"turquoise" => Ok(Color::Turquoise), "turquoise" => Ok(Self::Turquoise),
"violet" => Ok(Color::Violet), "violet" => Ok(Self::Violet),
"wheat" => Ok(Color::Wheat), "wheat" => Ok(Self::Wheat),
"white" => Ok(Color::White), "white" => Ok(Self::White),
"whitesmoke" => Ok(Color::WhiteSmoke), "whitesmoke" => Ok(Self::WhiteSmoke),
"yellow" => Ok(Color::Yellow), "yellow" => Ok(Self::Yellow),
"yellowgreen" => Ok(Color::YellowGreen), "yellowgreen" => Ok(Self::YellowGreen),
_ => Err("invalid color"), _ => Err("invalid color"),
} }
} }

View File

@ -67,33 +67,33 @@ pub enum Symbol {
impl Display for Symbol { impl Display for Symbol {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Symbol::Period => write!(f, "."), Self::Period => write!(f, "."),
Symbol::Hash => write!(f, "#"), Self::Hash => write!(f, "#"),
Symbol::At => write!(f, "@"), Self::At => write!(f, "@"),
Symbol::Dollar => write!(f, "$"), Self::Dollar => write!(f, "$"),
Symbol::OpenParen => write!(f, "("), Self::OpenParen => write!(f, "("),
Symbol::CloseParen => write!(f, "),"), Self::CloseParen => write!(f, "),"),
Symbol::OpenCurlyBrace => write!(f, "{{"), Self::OpenCurlyBrace => write!(f, "{{"),
Symbol::CloseCurlyBrace => write!(f, "}}"), Self::CloseCurlyBrace => write!(f, "}}"),
Symbol::OpenSquareBrace => write!(f, "["), Self::OpenSquareBrace => write!(f, "["),
Symbol::CloseSquareBrace => write!(f, "]"), Self::CloseSquareBrace => write!(f, "]"),
Symbol::Comma => write!(f, ","), Self::Comma => write!(f, ","),
Symbol::Plus => write!(f, "+"), Self::Plus => write!(f, "+"),
Symbol::Minus => write!(f, "-"), Self::Minus => write!(f, "-"),
Symbol::Mul => write!(f, "*"), Self::Mul => write!(f, "*"),
Symbol::Div => write!(f, "/"), Self::Div => write!(f, "/"),
Symbol::Colon => write!(f, ":"), Self::Colon => write!(f, ":"),
Symbol::SemiColon => write!(f, ";"), Self::SemiColon => write!(f, ";"),
Symbol::Tilde => write!(f, "~"), Self::Tilde => write!(f, "~"),
Symbol::Gt => write!(f, ">"), Self::Gt => write!(f, ">"),
Symbol::Lt => write!(f, "<"), Self::Lt => write!(f, "<"),
Symbol::Xor => write!(f, "^"), Self::Xor => write!(f, "^"),
Symbol::Equal => write!(f, "="), Self::Equal => write!(f, "="),
Symbol::BitOr => write!(f, "|"), Self::BitOr => write!(f, "|"),
Symbol::BitAnd => write!(f, "&"), Self::BitAnd => write!(f, "&"),
Symbol::Percent => write!(f, "%"), Self::Percent => write!(f, "%"),
Symbol::DoubleQuote => write!(f, "\""), Self::DoubleQuote => write!(f, "\""),
Symbol::SingleQuote => write!(f, "'"), Self::SingleQuote => write!(f, "'"),
} }
} }
} }
@ -103,33 +103,33 @@ impl TryFrom<char> for Symbol {
fn try_from(c: char) -> Result<Self, Self::Error> { fn try_from(c: char) -> Result<Self, Self::Error> {
match c { match c {
'.' => Ok(Symbol::Period), '.' => Ok(Self::Period),
'#' => Ok(Symbol::Hash), '#' => Ok(Self::Hash),
'@' => Ok(Symbol::At), '@' => Ok(Self::At),
'$' => Ok(Symbol::Dollar), '$' => Ok(Self::Dollar),
'(' => Ok(Symbol::OpenParen), '(' => Ok(Self::OpenParen),
')' => Ok(Symbol::CloseParen), ')' => Ok(Self::CloseParen),
'{' => Ok(Symbol::OpenCurlyBrace), '{' => Ok(Self::OpenCurlyBrace),
'}' => Ok(Symbol::CloseCurlyBrace), '}' => Ok(Self::CloseCurlyBrace),
'[' => Ok(Symbol::OpenSquareBrace), '[' => Ok(Self::OpenSquareBrace),
']' => Ok(Symbol::CloseSquareBrace), ']' => Ok(Self::CloseSquareBrace),
',' => Ok(Symbol::Comma), ',' => Ok(Self::Comma),
'+' => Ok(Symbol::Plus), '+' => Ok(Self::Plus),
'-' => Ok(Symbol::Minus), '-' => Ok(Self::Minus),
'*' => Ok(Symbol::Mul), '*' => Ok(Self::Mul),
'/' => Ok(Symbol::Div), '/' => Ok(Self::Div),
':' => Ok(Symbol::Colon), ':' => Ok(Self::Colon),
';' => Ok(Symbol::SemiColon), ';' => Ok(Self::SemiColon),
'~' => Ok(Symbol::Tilde), '~' => Ok(Self::Tilde),
'>' => Ok(Symbol::Gt), '>' => Ok(Self::Gt),
'<' => Ok(Symbol::Lt), '<' => Ok(Self::Lt),
'^' => Ok(Symbol::Xor), '^' => Ok(Self::Xor),
'=' => Ok(Symbol::Equal), '=' => Ok(Self::Equal),
'|' => Ok(Symbol::BitOr), '|' => Ok(Self::BitOr),
'&' => Ok(Symbol::BitAnd), '&' => Ok(Self::BitAnd),
'%' => Ok(Symbol::Percent), '%' => Ok(Self::Percent),
'"' => Ok(Symbol::DoubleQuote), '"' => Ok(Self::DoubleQuote),
'\'' => Ok(Symbol::SingleQuote), '\'' => Ok(Self::SingleQuote),
_ => Err("invalid symbol"), _ => Err("invalid symbol"),
} }
} }
@ -211,38 +211,38 @@ impl TryFrom<&str> for AtRule {
fn try_from(c: &str) -> Result<Self, &'static str> { fn try_from(c: &str) -> Result<Self, &'static str> {
match c { match c {
"use" => Ok(AtRule::Use), "use" => Ok(Self::Use),
"forward" => Ok(AtRule::Forward), "forward" => Ok(Self::Forward),
"import" => Ok(AtRule::Import), "import" => Ok(Self::Import),
"mixin" => Ok(AtRule::Mixin), "mixin" => Ok(Self::Mixin),
"include" => Ok(AtRule::Include), "include" => Ok(Self::Include),
"function" => Ok(AtRule::Function), "function" => Ok(Self::Function),
"extend" => Ok(AtRule::Extend), "extend" => Ok(Self::Extend),
"atroot" => Ok(AtRule::AtRoot), "atroot" => Ok(Self::AtRoot),
"error" => Ok(AtRule::Error), "error" => Ok(Self::Error),
"warn" => Ok(AtRule::Warn), "warn" => Ok(Self::Warn),
"debug" => Ok(AtRule::Debug), "debug" => Ok(Self::Debug),
"if" => Ok(AtRule::If), "if" => Ok(Self::If),
"each" => Ok(AtRule::Each), "each" => Ok(Self::Each),
"for" => Ok(AtRule::For), "for" => Ok(Self::For),
"while" => Ok(AtRule::While), "while" => Ok(Self::While),
"charset" => Ok(AtRule::Charset), "charset" => Ok(Self::Charset),
"namespace" => Ok(AtRule::Namespace), "namespace" => Ok(Self::Namespace),
"media" => Ok(AtRule::Media), "media" => Ok(Self::Media),
"supports" => Ok(AtRule::Supports), "supports" => Ok(Self::Supports),
"page" => Ok(AtRule::Page), "page" => Ok(Self::Page),
"fontface" => Ok(AtRule::FontFace), "fontface" => Ok(Self::FontFace),
"keyframes" => Ok(AtRule::Keyframes), "keyframes" => Ok(Self::Keyframes),
"fontfeaturevalues" => Ok(AtRule::FontFeatureValues), "fontfeaturevalues" => Ok(Self::FontFeatureValues),
"swash" => Ok(AtRule::Swash), "swash" => Ok(Self::Swash),
"ornaments" => Ok(AtRule::Ornaments), "ornaments" => Ok(Self::Ornaments),
"annotation" => Ok(AtRule::Annotation), "annotation" => Ok(Self::Annotation),
"stylistic" => Ok(AtRule::Stylistic), "stylistic" => Ok(Self::Stylistic),
"styleset" => Ok(AtRule::Styleset), "styleset" => Ok(Self::Styleset),
"charactervariant" => Ok(AtRule::CharacterVariant), "charactervariant" => Ok(Self::CharacterVariant),
"viewport" => Ok(AtRule::Viewport), "viewport" => Ok(Self::Viewport),
"document" => Ok(AtRule::Document), "document" => Ok(Self::Document),
"counterstyle" => Ok(AtRule::CounterStyle), "counterstyle" => Ok(Self::CounterStyle),
_ => Err("invalid at rule"), _ => Err("invalid at rule"),
} }
} }
@ -251,38 +251,38 @@ impl TryFrom<&str> for AtRule {
impl Display for AtRule { impl Display for AtRule {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
AtRule::Use => write!(f, "@use"), Self::Use => write!(f, "@use"),
AtRule::Forward => write!(f, "@forward"), Self::Forward => write!(f, "@forward"),
AtRule::Import => write!(f, "@import"), Self::Import => write!(f, "@import"),
AtRule::Mixin => write!(f, "@mixin"), Self::Mixin => write!(f, "@mixin"),
AtRule::Include => write!(f, "@include"), Self::Include => write!(f, "@include"),
AtRule::Function => write!(f, "@function"), Self::Function => write!(f, "@function"),
AtRule::Extend => write!(f, "@extend"), Self::Extend => write!(f, "@extend"),
AtRule::AtRoot => write!(f, "@atroot"), Self::AtRoot => write!(f, "@atroot"),
AtRule::Error => write!(f, "@error"), Self::Error => write!(f, "@error"),
AtRule::Warn => write!(f, "@warn"), Self::Warn => write!(f, "@warn"),
AtRule::Debug => write!(f, "@debug"), Self::Debug => write!(f, "@debug"),
AtRule::If => write!(f, "@if"), Self::If => write!(f, "@if"),
AtRule::Each => write!(f, "@each"), Self::Each => write!(f, "@each"),
AtRule::For => write!(f, "@for"), Self::For => write!(f, "@for"),
AtRule::While => write!(f, "@while"), Self::While => write!(f, "@while"),
AtRule::Charset => write!(f, "@charset"), Self::Charset => write!(f, "@charset"),
AtRule::Namespace => write!(f, "@namespace"), Self::Namespace => write!(f, "@namespace"),
AtRule::Media => write!(f, "@media"), Self::Media => write!(f, "@media"),
AtRule::Supports => write!(f, "@supports"), Self::Supports => write!(f, "@supports"),
AtRule::Page => write!(f, "@page"), Self::Page => write!(f, "@page"),
AtRule::FontFace => write!(f, "@fontface"), Self::FontFace => write!(f, "@fontface"),
AtRule::Keyframes => write!(f, "@keyframes"), Self::Keyframes => write!(f, "@keyframes"),
AtRule::FontFeatureValues => write!(f, "@fontfeaturevalues"), Self::FontFeatureValues => write!(f, "@fontfeaturevalues"),
AtRule::Swash => write!(f, "@swash"), Self::Swash => write!(f, "@swash"),
AtRule::Ornaments => write!(f, "@ornaments"), Self::Ornaments => write!(f, "@ornaments"),
AtRule::Annotation => write!(f, "@annotation"), Self::Annotation => write!(f, "@annotation"),
AtRule::Stylistic => write!(f, "@stylistic"), Self::Stylistic => write!(f, "@stylistic"),
AtRule::Styleset => write!(f, "@styleset"), Self::Styleset => write!(f, "@styleset"),
AtRule::CharacterVariant => write!(f, "@charactervariant"), Self::CharacterVariant => write!(f, "@charactervariant"),
AtRule::Viewport => write!(f, "@viewport"), Self::Viewport => write!(f, "@viewport"),
AtRule::Document => write!(f, "@document"), Self::Document => write!(f, "@document"),
AtRule::CounterStyle => write!(f, "@counterstyle"), Self::CounterStyle => write!(f, "@counterstyle"),
} }
} }
} }
@ -298,10 +298,10 @@ pub enum Whitespace {
impl Display for Whitespace { impl Display for Whitespace {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Whitespace::Space => write!(f, " "), Self::Space => write!(f, " "),
Whitespace::Tab => write!(f, "\t"), Self::Tab => write!(f, "\t"),
Whitespace::Newline => writeln!(f), Self::Newline => writeln!(f),
Whitespace::CarriageReturn => write!(f, "\r"), Self::CarriageReturn => write!(f, "\r"),
} }
} }
} }
@ -311,10 +311,10 @@ impl TryFrom<char> for Whitespace {
fn try_from(c: char) -> Result<Self, Self::Error> { fn try_from(c: char) -> Result<Self, Self::Error> {
match c { match c {
' ' => Ok(Whitespace::Space), ' ' => Ok(Self::Space),
'\t' => Ok(Whitespace::Tab), '\t' => Ok(Self::Tab),
'\n' => Ok(Whitespace::Newline), '\n' => Ok(Self::Newline),
'\r' => Ok(Whitespace::CarriageReturn), '\r' => Ok(Self::CarriageReturn),
_ => Err("invalid whitespace"), _ => Err("invalid whitespace"),
} }
} }
@ -333,12 +333,12 @@ pub enum Op {
impl Display for Op { impl Display for Op {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Op::Equal => write!(f, "=="), Self::Equal => write!(f, "=="),
Op::NotEqual => write!(f, "!="), Self::NotEqual => write!(f, "!="),
Op::GreaterThanEqual => write!(f, ">="), Self::GreaterThanEqual => write!(f, ">="),
Op::LessThanEqual => write!(f, "<="), Self::LessThanEqual => write!(f, "<="),
Op::GreaterThan => write!(f, ">"), Self::GreaterThan => write!(f, ">"),
Op::LessThan => write!(f, "<"), Self::LessThan => write!(f, "<"),
} }
} }
} }
@ -364,20 +364,20 @@ pub enum Keyword {
impl Display for Keyword { impl Display for Keyword {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Keyword::Important => write!(f, "!important"), Self::Important => write!(f, "!important"),
Keyword::Infinity => write!(f, "Infinity"), Self::Infinity => write!(f, "Infinity"),
Keyword::NaN => write!(f, "NaN"), Self::NaN => write!(f, "NaN"),
Keyword::Auto => write!(f, "auto"), Self::Auto => write!(f, "auto"),
Keyword::Inherit => write!(f, "inherit"), Self::Inherit => write!(f, "inherit"),
Keyword::Initial => write!(f, "initial"), Self::Initial => write!(f, "initial"),
Keyword::Unset => write!(f, "unset"), Self::Unset => write!(f, "unset"),
Keyword::True => write!(f, "true"), Self::True => write!(f, "true"),
Keyword::False => write!(f, "false"), Self::False => write!(f, "false"),
Keyword::Not => write!(f, "not"), Self::Not => write!(f, "not"),
Keyword::And => write!(f, "and"), Self::And => write!(f, "and"),
Keyword::Or => write!(f, "or"), Self::Or => write!(f, "or"),
Keyword::Null => write!(f, "null"), Self::Null => write!(f, "null"),
Keyword::In => write!(f, "in"), Self::In => write!(f, "in"),
} }
} }
} }
@ -385,20 +385,20 @@ impl Display for Keyword {
impl Into<&'static str> for Keyword { impl Into<&'static str> for Keyword {
fn into(self) -> &'static str { fn into(self) -> &'static str {
match self { match self {
Keyword::Important => "!important", Self::Important => "!important",
Keyword::Infinity => "Infinity", Self::Infinity => "Infinity",
Keyword::NaN => "NaN", Self::NaN => "NaN",
Keyword::Auto => "auto", Self::Auto => "auto",
Keyword::Inherit => "inherit", Self::Inherit => "inherit",
Keyword::Initial => "initial", Self::Initial => "initial",
Keyword::Unset => "unset", Self::Unset => "unset",
Keyword::True => "true", Self::True => "true",
Keyword::False => "false", Self::False => "false",
Keyword::Not => "not", Self::Not => "not",
Keyword::And => "and", Self::And => "and",
Keyword::Or => "or", Self::Or => "or",
Keyword::Null => "null", Self::Null => "null",
Keyword::In => "in", Self::In => "in",
} }
} }
} }
@ -409,20 +409,20 @@ impl TryFrom<&str> for Keyword {
fn try_from(kw: &str) -> Result<Self, Self::Error> { fn try_from(kw: &str) -> Result<Self, Self::Error> {
// todo: case insensitive? // todo: case insensitive?
match kw { match kw {
"important" => Ok(Keyword::Important), "important" => Ok(Self::Important),
"infinity" => Ok(Keyword::Infinity), "infinity" => Ok(Self::Infinity),
"nan" => Ok(Keyword::NaN), "nan" => Ok(Self::NaN),
"auto" => Ok(Keyword::Auto), "auto" => Ok(Self::Auto),
"inherit" => Ok(Keyword::Inherit), "inherit" => Ok(Self::Inherit),
"initial" => Ok(Keyword::Initial), "initial" => Ok(Self::Initial),
"unset" => Ok(Keyword::Unset), "unset" => Ok(Self::Unset),
"true" => Ok(Keyword::True), "true" => Ok(Self::True),
"false" => Ok(Keyword::False), "false" => Ok(Self::False),
"not" => Ok(Keyword::Not), "not" => Ok(Self::Not),
"and" => Ok(Keyword::And), "and" => Ok(Self::And),
"or" => Ok(Keyword::Or), "or" => Ok(Self::Or),
"null" => Ok(Keyword::Null), "null" => Ok(Self::Null),
"in" => Ok(Keyword::In), "in" => Ok(Self::In),
_ => Err("invalid keyword"), _ => Err("invalid keyword"),
} }
} }