[librsvg: 5/9] make clippy happy




commit 6fafdadd16741e357aa28157ec0b39bc60051077
Author: Jordan Petridis <jordan centricular com>
Date:   Sun Jan 16 19:50:59 2022 +0200

    make clippy happy

 src/aspect_ratio.rs |  4 ++--
 src/filter.rs       |  8 +-------
 src/filter_func.rs  | 10 +++++-----
 src/gradient.rs     |  7 +------
 src/paint_server.rs |  2 +-
 5 files changed, 10 insertions(+), 21 deletions(-)
---
diff --git a/src/aspect_ratio.rs b/src/aspect_ratio.rs
index c9e8a36e8..8003f9f2e 100644
--- a/src/aspect_ratio.rs
+++ b/src/aspect_ratio.rs
@@ -231,8 +231,8 @@ impl Parse for AspectRatio {
             .try_parse(|p| p.expect_ident_matching("defer"))
             .is_ok();
 
-        let align_xy = parser.try_parse(|p| parse_align_xy(p))?;
-        let fit = parser.try_parse(|p| parse_fit_mode(p)).unwrap_or_default();
+        let align_xy = parser.try_parse(parse_align_xy)?;
+        let fit = parser.try_parse(parse_fit_mode).unwrap_or_default();
         let align = align_xy.map(|(x, y)| Align { x, y, fit });
 
         Ok(AspectRatio { defer, align })
diff --git a/src/filter.rs b/src/filter.rs
index 660beb41e..98552aea8 100644
--- a/src/filter.rs
+++ b/src/filter.rs
@@ -166,15 +166,9 @@ fn filter_spec_from_filter_node(
         })
 }
 
-#[derive(Debug, Clone, PartialEq)]
+#[derive(Debug, Default, Clone, PartialEq)]
 pub struct FilterValueList(Vec<FilterValue>);
 
-impl Default for FilterValueList {
-    fn default() -> FilterValueList {
-        FilterValueList(vec![])
-    }
-}
-
 impl FilterValueList {
     pub fn is_empty(&self) -> bool {
         self.0.is_empty()
diff --git a/src/filter_func.rs b/src/filter_func.rs
index ece4e9f2b..5820f38f5 100644
--- a/src/filter_func.rs
+++ b/src/filter_func.rs
@@ -192,13 +192,13 @@ fn parse_dropshadow<'i>(parser: &mut Parser<'i, '_>) -> Result<FilterFunction, P
         std_deviation: None,
     };
 
-    result.color = parser.try_parse(|p| Color::parse(p)).ok();
+    result.color = parser.try_parse(Color::parse).ok();
 
     // if dx is provided, dy must follow and an optional std_dev must follow that.
-    if let Ok(dx) = parser.try_parse(|p| Length::parse(p)) {
+    if let Ok(dx) = parser.try_parse(Length::parse) {
         result.dx = Some(dx);
-        result.dy = Some(parser.try_parse(|p| Length::parse(p))?);
-        result.std_deviation = parser.try_parse(|p| ULength::parse(p)).ok();
+        result.dy = Some(parser.try_parse(Length::parse)?);
+        result.std_deviation = parser.try_parse(ULength::parse).ok();
     }
 
     let loc = parser.current_source_location();
@@ -206,7 +206,7 @@ fn parse_dropshadow<'i>(parser: &mut Parser<'i, '_>) -> Result<FilterFunction, P
     // because the color and length arguments can be provided in either order,
     // check again after potentially parsing lengths if the color is now provided.
     // if a color is provided both before and after, that is an error.
-    if let Ok(c) = parser.try_parse(|p| Color::parse(p)) {
+    if let Ok(c) = parser.try_parse(Color::parse) {
         if result.color.is_some() {
             return Err(
                 loc.new_custom_error(ValueErrorKind::Value("color already specified".to_string()))
diff --git a/src/gradient.rs b/src/gradient.rs
index d2a35e888..abe374e19 100644
--- a/src/gradient.rs
+++ b/src/gradient.rs
@@ -689,12 +689,7 @@ impl ResolvedGradient {
         values: &ComputedValues,
     ) -> Option<UserSpaceGradient> {
         let units = self.units.0;
-        let transform = if let Ok(t) = bbox.rect_to_transform(units) {
-            t
-        } else {
-            return None;
-        };
-
+        let transform = bbox.rect_to_transform(units).ok()?;
         let view_params = current_params.with_units(units);
         let params = NormalizeParams::new(values, &view_params);
 
diff --git a/src/paint_server.rs b/src/paint_server.rs
index e4c75f15a..a744c7286 100644
--- a/src/paint_server.rs
+++ b/src/paint_server.rs
@@ -92,7 +92,7 @@ impl Parse for PaintServer {
                 {
                     None
                 } else {
-                    Some(parser.try_parse(|i| cssparser::Color::parse(i))?)
+                    Some(parser.try_parse(cssparser::Color::parse)?)
                 }
             } else {
                 None


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