[librsvg: 2/8] Add a DeclarationList.iter() method
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 2/8] Add a DeclarationList.iter() method
- Date: Fri, 3 May 2019 19:25:32 +0000 (UTC)
commit ebe3479f9d8b2c98c00a597edc92e259ed054bb2
Author: Federico Mena Quintero <federico gnome org>
Date: Fri May 3 13:15:25 2019 -0500
Add a DeclarationList.iter() method
rsvg_internals/src/css.rs | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/rsvg_internals/src/css.rs b/rsvg_internals/src/css.rs
index 00032b24..986d0db5 100644
--- a/rsvg_internals/src/css.rs
+++ b/rsvg_internals/src/css.rs
@@ -1,5 +1,5 @@
use cssparser::{Parser, ParserInput};
-use std::collections::hash_map::Entry;
+use std::collections::hash_map::{Entry, Iter as HashMapIter};
use std::collections::{HashMap, HashSet};
use std::ptr;
use std::str::{self, FromStr};
@@ -53,6 +53,20 @@ impl DeclarationList {
}
}
}
+
+ pub fn iter(&self) -> DeclarationListIter {
+ DeclarationListIter(self.declarations.iter())
+ }
+}
+
+pub struct DeclarationListIter<'a>(HashMapIter<'a, Attribute, Declaration>);
+
+impl<'a> Iterator for DeclarationListIter<'a> {
+ type Item = &'a Declaration;
+
+ fn next(&mut self) -> Option<Self::Item> {
+ self.0.next().map(|(_attribute, declaration)| declaration)
+ }
}
impl CssRules {
@@ -146,7 +160,7 @@ impl CssRules {
important_styles: &mut HashSet<Attribute>,
) -> bool {
if let Some(decl_list) = self.selectors_to_declarations.get(selector) {
- for (_, declaration) in decl_list.declarations.iter() {
+ for declaration in decl_list.iter() {
values.set_property_from_declaration(declaration, important_styles);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]