[librsvg: 5/30] morphology: use NonNegative for parsing
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 5/30] morphology: use NonNegative for parsing
- Date: Mon, 28 Dec 2020 20:06:29 +0000 (UTC)
commit c4003296e3403cc9a141eb433d9573fc6365370e
Author: Paolo Borelli <pborelli gnome org>
Date: Wed Dec 23 17:58:02 2020 +0100
morphology: use NonNegative for parsing
src/filters/morphology.rs | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
---
diff --git a/src/filters/morphology.rs b/src/filters/morphology.rs
index 14744cd9..c95246b2 100644
--- a/src/filters/morphology.rs
+++ b/src/filters/morphology.rs
@@ -9,7 +9,7 @@ use crate::drawing_ctx::DrawingCtx;
use crate::element::{ElementResult, SetAttributes};
use crate::error::*;
use crate::node::Node;
-use crate::parsers::{NumberOptionalNumber, Parse, ParseValue};
+use crate::parsers::{NonNegative, NumberOptionalNumber, Parse, ParseValue};
use crate::rect::IRect;
use crate::surface_utils::{
iterators::{PixelRectangle, Pixels},
@@ -53,15 +53,7 @@ impl SetAttributes for FeMorphology {
match attr.expanded() {
expanded_name!("", "operator") => self.operator = attr.parse(value)?,
expanded_name!("", "radius") => {
- 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("radius cannot be negative"))
- }
- })?;
-
+ let NumberOptionalNumber(NonNegative(x), NonNegative(y)) = attr.parse(value)?;
self.radius = (x, y);
}
_ => (),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]