[librsvg: 4/30] turbolence: use NonNegative for parsing




commit 1218b82424368fcd5412ba7d7c648cfc6ed14a5d
Author: Paolo Borelli <pborelli gnome org>
Date:   Wed Dec 23 17:57:38 2020 +0100

    turbolence: use NonNegative for parsing

 src/filters/turbulence.rs | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
---
diff --git a/src/filters/turbulence.rs b/src/filters/turbulence.rs
index 253bd4c4..79b8fe48 100644
--- a/src/filters/turbulence.rs
+++ b/src/filters/turbulence.rs
@@ -7,7 +7,7 @@ use crate::drawing_ctx::DrawingCtx;
 use crate::element::{ElementResult, SetAttributes};
 use crate::error::*;
 use crate::node::{CascadedValues, Node};
-use crate::parsers::{NumberOptionalNumber, Parse, ParseValue};
+use crate::parsers::{NonNegative, NumberOptionalNumber, Parse, ParseValue};
 use crate::surface_utils::{
     shared_surface::{ExclusiveImageSurface, SurfaceType},
     ImageSurfaceDataExt, Pixel, PixelOps,
@@ -63,15 +63,7 @@ impl SetAttributes for FeTurbulence {
         for (attr, value) in attrs.iter() {
             match attr.expanded() {
                 expanded_name!("", "baseFrequency") => {
-                    let NumberOptionalNumber(x, y) =
-                        attr.parse_and_validate(value, |v: NumberOptionalNumber<f64>| {
-                            if v.0 >= 0.0 && v.1 >= 0.0 {
-                                Ok(v)
-                            } else {
-                                Err(ValueErrorKind::value_error("values can't be negative"))
-                            }
-                        })?;
-
+                    let NumberOptionalNumber(NonNegative(x), NonNegative(y)) = attr.parse(value)?;
                     self.base_frequency = (x, y);
                 }
                 expanded_name!("", "numOctaves") => {


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