[librsvg: 41/51] convolve_matrix.rs: impl Parse for EdgeMode instead of using a custom method
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 41/51] convolve_matrix.rs: impl Parse for EdgeMode instead of using a custom method
- Date: Thu, 19 Dec 2019 01:51:28 +0000 (UTC)
commit 62c0cffbb988b306e1d4bdbb0b60e13a3c049409
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Dec 18 10:35:29 2019 -0600
convolve_matrix.rs: impl Parse for EdgeMode instead of using a custom method
rsvg_internals/src/filters/convolve_matrix.rs | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
---
diff --git a/rsvg_internals/src/filters/convolve_matrix.rs b/rsvg_internals/src/filters/convolve_matrix.rs
index 3816df86..0747ddd8 100644
--- a/rsvg_internals/src/filters/convolve_matrix.rs
+++ b/rsvg_internals/src/filters/convolve_matrix.rs
@@ -86,7 +86,7 @@ impl NodeTrait for FeConvolveMatrix {
)
}
expanded_name!(svg "bias") => self.bias = parsers::number(value).attribute(attr)?,
- expanded_name!(svg "edgeMode") => self.edge_mode = EdgeMode::parse(attr, value)?,
+ expanded_name!(svg "edgeMode") => self.edge_mode = attr.parse(value)?,
expanded_name!(svg "kernelUnitLength") => {
self.kernel_unit_length = Some(
parsers::number_optional_number(value)
@@ -345,14 +345,15 @@ impl FilterEffect for FeConvolveMatrix {
}
}
-impl EdgeMode {
- fn parse(attr: QualName, s: &str) -> Result<Self, NodeError> {
- match s {
- "duplicate" => Ok(EdgeMode::Duplicate),
- "wrap" => Ok(EdgeMode::Wrap),
- "none" => Ok(EdgeMode::None),
- _ => Err(ValueErrorKind::parse_error("invalid value")).attribute(attr),
- }
+impl Parse for EdgeMode {
+ fn parse(parser: &mut Parser<'_, '_>) -> Result<Self, ValueErrorKind> {
+ parse_identifiers!(
+ parser,
+ "duplicate" => EdgeMode::Duplicate,
+ "wrap" => EdgeMode::Wrap,
+ "none" => EdgeMode::None,
+ )
+ .map_err(|_: ParseError| ValueErrorKind::parse_error("parse error"))
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]