[librsvg: 5/20] Derive Default for Primitive
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 5/20] Derive Default for Primitive
- Date: Wed, 17 Mar 2021 19:08:05 +0000 (UTC)
commit 2d3ecf075d304e6e8de00fdd3beb7a2d56619cde
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Mar 16 12:35:27 2021 -0600
Derive Default for Primitive
This removes Primitive::new().
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 | 2 +-
src/filters/gaussian_blur.rs | 2 +-
src/filters/image.rs | 2 +-
src/filters/lighting.rs | 4 ++--
src/filters/merge.rs | 2 +-
src/filters/mod.rs | 14 +-------------
src/filters/morphology.rs | 2 +-
src/filters/offset.rs | 2 +-
src/filters/tile.rs | 2 +-
src/filters/turbulence.rs | 2 +-
16 files changed, 17 insertions(+), 29 deletions(-)
---
diff --git a/src/filters/blend.rs b/src/filters/blend.rs
index 99f910ed..d026098a 100755
--- a/src/filters/blend.rs
+++ b/src/filters/blend.rs
@@ -57,7 +57,7 @@ impl Default for FeBlend {
#[inline]
fn default() -> FeBlend {
FeBlend {
- base: Primitive::new(),
+ base: Default::default(),
in1: Default::default(),
in2: Default::default(),
mode: Mode::default(),
diff --git a/src/filters/color_matrix.rs b/src/filters/color_matrix.rs
index 3d8681e5..b8eda8f7 100644
--- a/src/filters/color_matrix.rs
+++ b/src/filters/color_matrix.rs
@@ -48,7 +48,7 @@ impl Default for FeColorMatrix {
#[inline]
fn default() -> FeColorMatrix {
FeColorMatrix {
- base: Primitive::new(),
+ base: Default::default(),
in1: Default::default(),
matrix: Matrix5::identity(),
}
diff --git a/src/filters/component_transfer.rs b/src/filters/component_transfer.rs
index 14e4fd6b..3580f4cf 100644
--- a/src/filters/component_transfer.rs
+++ b/src/filters/component_transfer.rs
@@ -37,7 +37,7 @@ impl Default for FeComponentTransfer {
#[inline]
fn default() -> FeComponentTransfer {
FeComponentTransfer {
- base: Primitive::new(),
+ base: Default::default(),
in1: Default::default(),
}
}
diff --git a/src/filters/composite.rs b/src/filters/composite.rs
index b44969a7..2ae4983a 100644
--- a/src/filters/composite.rs
+++ b/src/filters/composite.rs
@@ -53,7 +53,7 @@ impl Default for FeComposite {
#[inline]
fn default() -> FeComposite {
FeComposite {
- base: Primitive::new(),
+ base: Default::default(),
in1: Default::default(),
in2: Default::default(),
operator: Operator::Over,
diff --git a/src/filters/convolve_matrix.rs b/src/filters/convolve_matrix.rs
index bc52f120..e4614fcd 100644
--- a/src/filters/convolve_matrix.rs
+++ b/src/filters/convolve_matrix.rs
@@ -58,7 +58,7 @@ impl Default for FeConvolveMatrix {
#[inline]
fn default() -> FeConvolveMatrix {
FeConvolveMatrix {
- base: Primitive::new(),
+ base: Default::default(),
in1: Default::default(),
order: (3, 3),
kernel_matrix: None,
diff --git a/src/filters/displacement_map.rs b/src/filters/displacement_map.rs
index dce4c9d5..847562f1 100644
--- a/src/filters/displacement_map.rs
+++ b/src/filters/displacement_map.rs
@@ -48,7 +48,7 @@ impl Default for FeDisplacementMap {
#[inline]
fn default() -> FeDisplacementMap {
FeDisplacementMap {
- base: Primitive::new(),
+ base: Default::default(),
in1: Default::default(),
in2: Default::default(),
scale: 0.0,
diff --git a/src/filters/flood.rs b/src/filters/flood.rs
index 670819f8..0f99b32a 100644
--- a/src/filters/flood.rs
+++ b/src/filters/flood.rs
@@ -23,7 +23,7 @@ impl Default for FeFlood {
#[inline]
fn default() -> FeFlood {
FeFlood {
- base: Primitive::new(),
+ base: Default::default(),
}
}
}
diff --git a/src/filters/gaussian_blur.rs b/src/filters/gaussian_blur.rs
index bbb87ba1..f26ed204 100644
--- a/src/filters/gaussian_blur.rs
+++ b/src/filters/gaussian_blur.rs
@@ -44,7 +44,7 @@ impl Default for FeGaussianBlur {
#[inline]
fn default() -> FeGaussianBlur {
FeGaussianBlur {
- base: Primitive::new(),
+ base: Default::default(),
in1: Default::default(),
std_deviation: (0.0, 0.0),
}
diff --git a/src/filters/image.rs b/src/filters/image.rs
index 29f084fa..977d22a0 100644
--- a/src/filters/image.rs
+++ b/src/filters/image.rs
@@ -34,7 +34,7 @@ impl Default for FeImage {
#[inline]
fn default() -> FeImage {
FeImage {
- base: Primitive::new(),
+ base: Default::default(),
aspect: AspectRatio::default(),
href: None,
}
diff --git a/src/filters/lighting.rs b/src/filters/lighting.rs
index 4e404184..6b32b567 100644
--- a/src/filters/lighting.rs
+++ b/src/filters/lighting.rs
@@ -294,7 +294,7 @@ pub struct FeDiffuseLighting {
impl Default for FeDiffuseLighting {
fn default() -> Self {
Self {
- base: Primitive::new(),
+ base: Default::default(),
in1: Default::default(),
surface_scale: 1.0,
kernel_unit_length: None,
@@ -359,7 +359,7 @@ pub struct FeSpecularLighting {
impl Default for FeSpecularLighting {
fn default() -> Self {
Self {
- base: Primitive::new(),
+ base: Default::default(),
in1: Default::default(),
surface_scale: 1.0,
kernel_unit_length: None,
diff --git a/src/filters/merge.rs b/src/filters/merge.rs
index 71352b2b..efdcc70a 100644
--- a/src/filters/merge.rs
+++ b/src/filters/merge.rs
@@ -41,7 +41,7 @@ impl Default for FeMerge {
#[inline]
fn default() -> FeMerge {
FeMerge {
- base: Primitive::new(),
+ base: Default::default(),
}
}
}
diff --git a/src/filters/mod.rs b/src/filters/mod.rs
index 09b97db2..609cf160 100644
--- a/src/filters/mod.rs
+++ b/src/filters/mod.rs
@@ -78,7 +78,7 @@ pub enum PrimitiveParams {
}
/// The base filter primitive node containing common properties.
-#[derive(Clone)]
+#[derive(Default, Clone)]
pub struct Primitive {
x: Option<Length<Horizontal>>,
y: Option<Length<Vertical>>,
@@ -136,18 +136,6 @@ impl Parse for Input {
}
impl Primitive {
- /// Constructs a new `Primitive` with empty properties.
- #[inline]
- fn new() -> Primitive {
- Primitive {
- x: None,
- y: None,
- width: None,
- height: None,
- result: None,
- }
- }
-
fn resolve(&self) -> Result<ResolvedPrimitive, FilterError> {
Ok(ResolvedPrimitive {
x: self.x,
diff --git a/src/filters/morphology.rs b/src/filters/morphology.rs
index 00ab4523..5a72523f 100644
--- a/src/filters/morphology.rs
+++ b/src/filters/morphology.rs
@@ -48,7 +48,7 @@ impl Default for FeMorphology {
#[inline]
fn default() -> FeMorphology {
FeMorphology {
- base: Primitive::new(),
+ base: Default::default(),
in1: Default::default(),
operator: Operator::Erode,
radius: (0.0, 0.0),
diff --git a/src/filters/offset.rs b/src/filters/offset.rs
index 4ef8aeb7..d032121e 100644
--- a/src/filters/offset.rs
+++ b/src/filters/offset.rs
@@ -32,7 +32,7 @@ impl Default for FeOffset {
#[inline]
fn default() -> FeOffset {
FeOffset {
- base: Primitive::new(),
+ base: Default::default(),
in1: Default::default(),
dx: 0f64,
dy: 0f64,
diff --git a/src/filters/tile.rs b/src/filters/tile.rs
index 6197cb09..687cd731 100644
--- a/src/filters/tile.rs
+++ b/src/filters/tile.rs
@@ -25,7 +25,7 @@ impl Default for FeTile {
#[inline]
fn default() -> FeTile {
FeTile {
- base: Primitive::new(),
+ base: Default::default(),
in1: Default::default(),
}
}
diff --git a/src/filters/turbulence.rs b/src/filters/turbulence.rs
index 6acb341c..c26315ff 100644
--- a/src/filters/turbulence.rs
+++ b/src/filters/turbulence.rs
@@ -57,7 +57,7 @@ impl Default for FeTurbulence {
#[inline]
fn default() -> FeTurbulence {
FeTurbulence {
- base: Primitive::new(),
+ base: Default::default(),
base_frequency: (0.0, 0.0),
num_octaves: 1,
seed: 0,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]