[librsvg: 1/2] Hide implementation details of FilterValueList
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 1/2] Hide implementation details of FilterValueList
- Date: Wed, 9 Sep 2020 16:51:53 +0000 (UTC)
commit a9c46506f2170e1e69576545ef5cd9db034cd18c
Author: Sven Neumann <sven svenfoo org>
Date: Wed Sep 9 09:39:20 2020 +0200
Hide implementation details of FilterValueList
We can hide the fact that FilterValueList uses a Vector by providing
a method to create an Iterator over the contained values.
rsvg_internals/src/drawing_ctx.rs | 1 -
rsvg_internals/src/filter.rs | 9 +++++++--
2 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index 647691ec..6065198e 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -600,7 +600,6 @@ impl DrawingCtx {
)?;
let img_surface = filters
- .0
.iter()
.try_fold(
child_surface,
diff --git a/rsvg_internals/src/filter.rs b/rsvg_internals/src/filter.rs
index 90718732..e945e048 100644
--- a/rsvg_internals/src/filter.rs
+++ b/rsvg_internals/src/filter.rs
@@ -2,6 +2,7 @@
use cssparser::Parser;
use markup5ever::{expanded_name, local_name, namespace_url, ns};
+use std::slice::Iter;
use crate::bbox::BoundingBox;
use crate::coord_units::CoordUnits;
@@ -195,7 +196,7 @@ pub enum FilterValue {
URL(IRI),
}
#[derive(Debug, Clone, PartialEq)]
-pub struct FilterValueList(pub Vec<FilterValue>);
+pub struct FilterValueList(Vec<FilterValue>);
impl Default for FilterValueList {
fn default() -> FilterValueList {
@@ -208,6 +209,10 @@ impl FilterValueList {
self.0.is_empty()
}
+ pub fn iter(&self) -> Iter<FilterValue> {
+ self.0.iter()
+ }
+
/// Check that at least one filter URI exists and that all contained
/// URIs reference existing <filter> elements.
pub fn is_applicable(&self, node: &Node, acquired_nodes: &mut AcquiredNodes) -> bool {
@@ -215,7 +220,7 @@ impl FilterValueList {
return false;
}
- self.0.iter().all(|filter| match filter {
+ self.iter().all(|filter| match filter {
FilterValue::URL(IRI::Resource(filter_uri)) => {
match acquired_nodes.acquire(filter_uri) {
Ok(acquired) => {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]