[librsvg: 28/51] property_macros: use parse_identifiers! for the identifiers: case



commit 2ffe43929c84e0e83d68a686afb29b0b09d8da17
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Dec 17 19:55:29 2019 -0600

    property_macros: use parse_identifiers! for the identifiers: case

 rsvg_internals/src/property_macros.rs | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)
---
diff --git a/rsvg_internals/src/property_macros.rs b/rsvg_internals/src/property_macros.rs
index f8745082..42ff6148 100644
--- a/rsvg_internals/src/property_macros.rs
+++ b/rsvg_internals/src/property_macros.rs
@@ -47,23 +47,10 @@ macro_rules! make_property {
 
         impl crate::parsers::Parse for $name {
             fn parse(parser: &mut ::cssparser::Parser<'_, '_>) -> Result<$name, 
crate::error::ValueErrorKind> {
-                let loc = parser.current_source_location();
-
-                parser
-                    .expect_ident()
-                    .and_then(|cow| match cow.as_ref() {
-                        $($str_prop => Ok($name::$variant),)+
-
-                            _ => Err(
-                                loc.new_basic_unexpected_token_error(
-                                    ::cssparser::Token::Ident(::cssparser::CowRcStr::from(
-                                        cow.as_ref().to_string(),
-                                    ))),
-                            ),
-                    })
-                    .map_err(|_| {
-                        crate::error::ValueErrorKind::parse_error("unexpected value")
-                    })
+                parse_identifiers!(
+                    parser,
+                    $($str_prop => $name::$variant,)+
+                ).map_err(|_e: crate::error::ParseError| crate::error::ValueErrorKind::parse_error("parse 
error"))
             }
         }
     };


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]