[librsvg: 14/36] style: remove interior mutability



commit 3872cb3fb368e4afc902c2ad95053ef1f8fdb4d1
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Jun 30 15:12:28 2019 +0200

    style: remove interior mutability

 rsvg_internals/src/style.rs | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
---
diff --git a/rsvg_internals/src/style.rs b/rsvg_internals/src/style.rs
index 5ad8575c..f0d83b1e 100644
--- a/rsvg_internals/src/style.rs
+++ b/rsvg_internals/src/style.rs
@@ -4,15 +4,13 @@ use crate::node::{NodeResult, NodeTrait, NodeType, RsvgNode};
 use crate::property_bag::PropertyBag;
 use crate::text::NodeChars;
 
-use std::cell::RefCell;
-
 /// Represents a <style> node.
 ///
 /// It does not render itself, and just holds CSS stylesheet information for the rest of
 /// the code to use.
 #[derive(Default)]
 pub struct NodeStyle {
-    type_: RefCell<Option<String>>,
+    type_: Option<String>,
 }
 
 impl NodeStyle {
@@ -26,12 +24,7 @@ impl NodeStyle {
         // "contentStyleType" attribute of the svg element, which in turn
         // defaults to "text/css".
 
-        let have_css = self
-            .type_
-            .borrow()
-            .as_ref()
-            .map(|t| t == "text/css")
-            .unwrap_or(true);
+        let have_css = self.type_.as_ref().map(|t| t == "text/css").unwrap_or(true);
 
         if have_css {
             node.children()
@@ -54,7 +47,7 @@ impl NodeTrait for NodeStyle {
     fn set_atts(&mut self, _: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
         for (attr, value) in pbag.iter() {
             if attr == local_name!("type") {
-                *self.type_.borrow_mut() = Some(value.to_string());
+                self.type_ = Some(value.to_string());
             }
         }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]