[librsvg/attribute-parsers-737: 21/26] filters::Primitive - make all the parse_*() methods infallible
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/attribute-parsers-737: 21/26] filters::Primitive - make all the parse_*() methods infallible
- Date: Fri, 21 Oct 2022 01:06:08 +0000 (UTC)
commit 1cbc5e741e3f897881b806411b0950b024975197
Author: Federico Mena Quintero <federico gnome org>
Date: Thu Oct 20 19:10:41 2022 -0500
filters::Primitive - make all the parse_*() methods infallible
Now that they fall back to the appropriate values, there's no need to
return a Result from them.
src/filters/blend.rs | 2 +-
src/filters/color_matrix.rs | 2 +-
src/filters/component_transfer.rs | 2 +-
src/filters/composite.rs | 2 +-
src/filters/convolve_matrix.rs | 2 +-
src/filters/displacement_map.rs | 2 +-
src/filters/flood.rs | 3 ++-
src/filters/gaussian_blur.rs | 2 +-
src/filters/image.rs | 2 +-
src/filters/lighting.rs | 4 ++--
src/filters/merge.rs | 3 ++-
src/filters/mod.rs | 29 ++++++++++-------------------
src/filters/morphology.rs | 2 +-
src/filters/offset.rs | 2 +-
src/filters/tile.rs | 2 +-
src/filters/turbulence.rs | 2 +-
16 files changed, 28 insertions(+), 35 deletions(-)
---
diff --git a/src/filters/blend.rs b/src/filters/blend.rs
index 96e962774..76263f9fe 100644
--- a/src/filters/blend.rs
+++ b/src/filters/blend.rs
@@ -61,7 +61,7 @@ pub struct Blend {
impl SetAttributes for FeBlend {
fn set_attributes(&mut self, attrs: &Attributes, session: &Session) -> ElementResult {
- let (in1, in2) = self.base.parse_two_inputs(attrs, session)?;
+ let (in1, in2) = self.base.parse_two_inputs(attrs, session);
self.params.in1 = in1;
self.params.in2 = in2;
diff --git a/src/filters/color_matrix.rs b/src/filters/color_matrix.rs
index 382404b7c..67ebafb1e 100644
--- a/src/filters/color_matrix.rs
+++ b/src/filters/color_matrix.rs
@@ -64,7 +64,7 @@ impl Default for ColorMatrix {
impl SetAttributes for FeColorMatrix {
fn set_attributes(&mut self, attrs: &Attributes, session: &Session) -> ElementResult {
- self.params.in1 = self.base.parse_one_input(attrs, session)?;
+ self.params.in1 = self.base.parse_one_input(attrs, session);
// First, determine the operation type.
let mut operation_type = Default::default();
diff --git a/src/filters/component_transfer.rs b/src/filters/component_transfer.rs
index 6237bbc60..20387db1f 100644
--- a/src/filters/component_transfer.rs
+++ b/src/filters/component_transfer.rs
@@ -42,7 +42,7 @@ pub struct ComponentTransfer {
impl SetAttributes for FeComponentTransfer {
fn set_attributes(&mut self, attrs: &Attributes, session: &Session) -> ElementResult {
- self.params.in1 = self.base.parse_one_input(attrs, session)?;
+ self.params.in1 = self.base.parse_one_input(attrs, session);
Ok(())
}
}
diff --git a/src/filters/composite.rs b/src/filters/composite.rs
index c0724b62b..90ef761fb 100644
--- a/src/filters/composite.rs
+++ b/src/filters/composite.rs
@@ -55,7 +55,7 @@ pub struct Composite {
impl SetAttributes for FeComposite {
fn set_attributes(&mut self, attrs: &Attributes, session: &Session) -> ElementResult {
- let (in1, in2) = self.base.parse_two_inputs(attrs, session)?;
+ let (in1, in2) = self.base.parse_two_inputs(attrs, session);
self.params.in1 = in1;
self.params.in2 = in2;
diff --git a/src/filters/convolve_matrix.rs b/src/filters/convolve_matrix.rs
index cceb03155..ec508cdc0 100644
--- a/src/filters/convolve_matrix.rs
+++ b/src/filters/convolve_matrix.rs
@@ -71,7 +71,7 @@ impl Default for ConvolveMatrix {
impl SetAttributes for FeConvolveMatrix {
fn set_attributes(&mut self, attrs: &Attributes, session: &Session) -> ElementResult {
- self.params.in1 = self.base.parse_one_input(attrs, session)?;
+ self.params.in1 = self.base.parse_one_input(attrs, session);
for (attr, value) in attrs.iter() {
match attr.expanded() {
diff --git a/src/filters/displacement_map.rs b/src/filters/displacement_map.rs
index 14f43c45e..c70804407 100644
--- a/src/filters/displacement_map.rs
+++ b/src/filters/displacement_map.rs
@@ -51,7 +51,7 @@ pub struct DisplacementMap {
impl SetAttributes for FeDisplacementMap {
fn set_attributes(&mut self, attrs: &Attributes, session: &Session) -> ElementResult {
- let (in1, in2) = self.base.parse_two_inputs(attrs, session)?;
+ let (in1, in2) = self.base.parse_two_inputs(attrs, session);
self.params.in1 = in1;
self.params.in2 = in2;
diff --git a/src/filters/flood.rs b/src/filters/flood.rs
index 40e20592b..d1bddeb03 100644
--- a/src/filters/flood.rs
+++ b/src/filters/flood.rs
@@ -26,7 +26,8 @@ pub struct Flood {
impl SetAttributes for FeFlood {
fn set_attributes(&mut self, attrs: &Attributes, session: &Session) -> ElementResult {
- self.base.parse_no_inputs(attrs, session)
+ self.base.parse_no_inputs(attrs, session);
+ Ok(())
}
}
diff --git a/src/filters/gaussian_blur.rs b/src/filters/gaussian_blur.rs
index bbdaf9316..6dc23c891 100644
--- a/src/filters/gaussian_blur.rs
+++ b/src/filters/gaussian_blur.rs
@@ -47,7 +47,7 @@ pub struct GaussianBlur {
impl SetAttributes for FeGaussianBlur {
fn set_attributes(&mut self, attrs: &Attributes, session: &Session) -> ElementResult {
- self.params.in1 = self.base.parse_one_input(attrs, session)?;
+ self.params.in1 = self.base.parse_one_input(attrs, session);
for (attr, value) in attrs.iter() {
if let expanded_name!("", "stdDeviation") = attr.expanded() {
diff --git a/src/filters/image.rs b/src/filters/image.rs
index ea24a4058..62e1349ae 100644
--- a/src/filters/image.rs
+++ b/src/filters/image.rs
@@ -117,7 +117,7 @@ impl Image {
impl SetAttributes for FeImage {
fn set_attributes(&mut self, attrs: &Attributes, session: &Session) -> ElementResult {
- self.base.parse_no_inputs(attrs, session)?;
+ self.base.parse_no_inputs(attrs, session);
for (attr, value) in attrs.iter() {
match attr.expanded() {
diff --git a/src/filters/lighting.rs b/src/filters/lighting.rs
index e173f1201..187815b11 100644
--- a/src/filters/lighting.rs
+++ b/src/filters/lighting.rs
@@ -334,7 +334,7 @@ fn transform_dist(t: Transform, d: f64) -> f64 {
impl SetAttributes for FeDiffuseLighting {
fn set_attributes(&mut self, attrs: &Attributes, session: &Session) -> ElementResult {
- self.params.in1 = self.base.parse_one_input(attrs, session)?;
+ self.params.in1 = self.base.parse_one_input(attrs, session);
for (attr, value) in attrs.iter() {
match attr.expanded() {
@@ -379,7 +379,7 @@ impl DiffuseLighting {
impl SetAttributes for FeSpecularLighting {
fn set_attributes(&mut self, attrs: &Attributes, session: &Session) -> ElementResult {
- self.params.in1 = self.base.parse_one_input(attrs, session)?;
+ self.params.in1 = self.base.parse_one_input(attrs, session);
for (attr, value) in attrs.iter() {
match attr.expanded() {
diff --git a/src/filters/merge.rs b/src/filters/merge.rs
index 0b3a13a3c..12db67276 100644
--- a/src/filters/merge.rs
+++ b/src/filters/merge.rs
@@ -53,7 +53,8 @@ impl Default for FeMerge {
impl SetAttributes for FeMerge {
fn set_attributes(&mut self, attrs: &Attributes, session: &Session) -> ElementResult {
- self.base.parse_no_inputs(attrs, session)
+ self.base.parse_no_inputs(attrs, session);
+ Ok(())
}
}
diff --git a/src/filters/mod.rs b/src/filters/mod.rs
index b4949387c..c2ec81686 100644
--- a/src/filters/mod.rs
+++ b/src/filters/mod.rs
@@ -8,8 +8,8 @@ use std::time::Instant;
use crate::bbox::BoundingBox;
use crate::document::AcquiredNodes;
use crate::drawing_ctx::DrawingCtx;
-use crate::element::{set_attribute, Draw, ElementResult, SetAttributes};
-use crate::error::{ElementError, ParseError, RenderingError};
+use crate::element::{set_attribute, Draw, SetAttributes};
+use crate::error::{ParseError, RenderingError};
use crate::filter::UserSpaceFilter;
use crate::length::*;
use crate::node::Node;
@@ -208,7 +208,7 @@ impl Primitive {
&mut self,
attrs: &Attributes,
session: &Session,
- ) -> Result<(Input, Input), ElementError> {
+ ) -> (Input, Input) {
let mut input_1 = Input::Unspecified;
let mut input_2 = Input::Unspecified;
@@ -233,28 +233,19 @@ impl Primitive {
}
}
- Ok((input_1, input_2))
+ (input_1, input_2)
}
- pub fn parse_no_inputs(&mut self, attrs: &Attributes, session: &Session) -> ElementResult {
- let (_, _) = self.parse_standard_attributes(attrs, session)?;
- Ok(())
+ pub fn parse_no_inputs(&mut self, attrs: &Attributes, session: &Session) {
+ let (_, _) = self.parse_standard_attributes(attrs, session);
}
- pub fn parse_one_input(
- &mut self,
- attrs: &Attributes,
- session: &Session,
- ) -> Result<Input, ElementError> {
- let (input_1, _) = self.parse_standard_attributes(attrs, session)?;
- Ok(input_1)
+ pub fn parse_one_input(&mut self, attrs: &Attributes, session: &Session) -> Input {
+ let (input_1, _) = self.parse_standard_attributes(attrs, session);
+ input_1
}
- pub fn parse_two_inputs(
- &mut self,
- attrs: &Attributes,
- session: &Session,
- ) -> Result<(Input, Input), ElementError> {
+ pub fn parse_two_inputs(&mut self, attrs: &Attributes, session: &Session) -> (Input, Input) {
self.parse_standard_attributes(attrs, session)
}
}
diff --git a/src/filters/morphology.rs b/src/filters/morphology.rs
index f440afa41..f518f76be 100644
--- a/src/filters/morphology.rs
+++ b/src/filters/morphology.rs
@@ -52,7 +52,7 @@ pub struct Morphology {
impl SetAttributes for FeMorphology {
fn set_attributes(&mut self, attrs: &Attributes, session: &Session) -> ElementResult {
- self.params.in1 = self.base.parse_one_input(attrs, session)?;
+ self.params.in1 = self.base.parse_one_input(attrs, session);
for (attr, value) in attrs.iter() {
match attr.expanded() {
diff --git a/src/filters/offset.rs b/src/filters/offset.rs
index 20f3b19c7..589f0e83b 100644
--- a/src/filters/offset.rs
+++ b/src/filters/offset.rs
@@ -34,7 +34,7 @@ pub struct Offset {
impl SetAttributes for FeOffset {
fn set_attributes(&mut self, attrs: &Attributes, session: &Session) -> ElementResult {
- self.params.in1 = self.base.parse_one_input(attrs, session)?;
+ self.params.in1 = self.base.parse_one_input(attrs, session);
for (attr, value) in attrs.iter() {
match attr.expanded() {
diff --git a/src/filters/tile.rs b/src/filters/tile.rs
index 4255443af..8f8552a71 100644
--- a/src/filters/tile.rs
+++ b/src/filters/tile.rs
@@ -29,7 +29,7 @@ pub struct Tile {
impl SetAttributes for FeTile {
fn set_attributes(&mut self, attrs: &Attributes, session: &Session) -> ElementResult {
- self.params.in1 = self.base.parse_one_input(attrs, session)?;
+ self.params.in1 = self.base.parse_one_input(attrs, session);
Ok(())
}
}
diff --git a/src/filters/turbulence.rs b/src/filters/turbulence.rs
index 3800161f1..a087b70d9 100644
--- a/src/filters/turbulence.rs
+++ b/src/filters/turbulence.rs
@@ -76,7 +76,7 @@ impl Default for Turbulence {
impl SetAttributes for FeTurbulence {
fn set_attributes(&mut self, attrs: &Attributes, session: &Session) -> ElementResult {
- self.base.parse_no_inputs(attrs, session)?;
+ self.base.parse_no_inputs(attrs, session);
for (attr, value) in attrs.iter() {
match attr.expanded() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]