[librsvg] NodeError: use a String for the attr_name, not a &'static str



commit 5ae4a79781beeee268e65ab92bf60110480ce19e
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Mar 16 07:48:20 2017 -0600

    NodeError: use a String for the attr_name, not a &'static str
    
    For now, we'll need to keep around attr_names that come from the C
    code.  We don't know if the pointers we are passed are to
    statically-allocated strings or not, so we'll just use full Strings on
    the heap for NodeError.

 rust/src/error.rs |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/rust/src/error.rs b/rust/src/error.rs
index b965fff..45475be 100644
--- a/rust/src/error.rs
+++ b/rust/src/error.rs
@@ -14,28 +14,28 @@ pub enum AttributeError {
 
 #[derive(Debug, Clone, PartialEq)]
 pub struct NodeError {
-    attr_name: &'static str,
+    attr_name: String,
     err:       AttributeError
 }
 
 impl NodeError {
-    pub fn parse_error (attr_name: &'static str, error: ParseError) -> NodeError {
+    pub fn parse_error (attr_name: &str, error: ParseError) -> NodeError {
         NodeError {
-            attr_name: attr_name,
+            attr_name: attr_name.to_string (),
             err: AttributeError::Parse (error)
         }
     }
 
-    pub fn value_error (attr_name: &'static str, description: String) -> NodeError {
+    pub fn value_error (attr_name: &str, description: String) -> NodeError {
         NodeError {
-            attr_name: attr_name,
+            attr_name: attr_name.to_string (),
             err: AttributeError::Value (description)
         }
     }
 
-    pub fn attribute_error (attr_name: &'static str, error: AttributeError) -> NodeError {
+    pub fn attribute_error (attr_name: &str, error: AttributeError) -> NodeError {
         NodeError {
-            attr_name: attr_name,
+            attr_name: attr_name.to_string (),
             err: error
         }
     }


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