@@ -28,25 +28,25 @@ impl Eq for RoNode {}
2828
2929impl RoNode {
3030 /// Returns the next sibling if it exists
31- pub fn get_next_sibling ( & self ) -> Option < RoNode > {
31+ pub fn get_next_sibling ( self ) -> Option < RoNode > {
3232 let ptr = xmlNextSibling ( self . 0 ) ;
3333 self . ptr_as_option ( ptr)
3434 }
3535
3636 /// Returns the previous sibling if it exists
37- pub fn get_prev_sibling ( & self ) -> Option < RoNode > {
37+ pub fn get_prev_sibling ( self ) -> Option < RoNode > {
3838 let ptr = xmlPrevSibling ( self . 0 ) ;
3939 self . ptr_as_option ( ptr)
4040 }
4141
4242 /// Returns the first child if it exists
43- pub fn get_first_child ( & self ) -> Option < RoNode > {
43+ pub fn get_first_child ( self ) -> Option < RoNode > {
4444 let ptr = xmlGetFirstChild ( self . 0 ) ;
4545 self . ptr_as_option ( ptr)
4646 }
4747
4848 /// Returns the first element child if it exists
49- pub fn get_first_element_child ( & self ) -> Option < RoNode > {
49+ pub fn get_first_element_child ( self ) -> Option < RoNode > {
5050 match self . get_first_child ( ) {
5151 None => None ,
5252 Some ( child) => {
@@ -68,13 +68,13 @@ impl RoNode {
6868 }
6969
7070 /// Returns the last child if it exists
71- pub fn get_last_child ( & self ) -> Option < RoNode > {
71+ pub fn get_last_child ( self ) -> Option < RoNode > {
7272 let ptr = unsafe { xmlGetLastChild ( self . 0 ) } ;
7373 self . ptr_as_option ( ptr)
7474 }
7575
7676 /// Returns all child nodes of the given node as a vector
77- pub fn get_child_nodes ( & self ) -> Vec < RoNode > {
77+ pub fn get_child_nodes ( self ) -> Vec < RoNode > {
7878 let mut children = Vec :: new ( ) ;
7979 if let Some ( first_child) = self . get_first_child ( ) {
8080 children. push ( first_child) ;
@@ -86,7 +86,7 @@ impl RoNode {
8686 }
8787
8888 /// Returns all child elements of the given node as a vector
89- pub fn get_child_elements ( & self ) -> Vec < RoNode > {
89+ pub fn get_child_elements ( self ) -> Vec < RoNode > {
9090 self
9191 . get_child_nodes ( )
9292 . into_iter ( )
@@ -95,33 +95,33 @@ impl RoNode {
9595 }
9696
9797 /// Returns the parent if it exists
98- pub fn get_parent ( & self ) -> Option < RoNode > {
98+ pub fn get_parent ( self ) -> Option < RoNode > {
9999 let ptr = xmlGetParent ( self . 0 ) ;
100100 self . ptr_as_option ( ptr)
101101 }
102102
103103 /// Get the node type
104- pub fn get_type ( & self ) -> Option < NodeType > {
104+ pub fn get_type ( self ) -> Option < NodeType > {
105105 NodeType :: from_int ( xmlGetNodeType ( self . 0 ) )
106106 }
107107
108108 /// Returns true iff it is a text node
109- pub fn is_text_node ( & self ) -> bool {
109+ pub fn is_text_node ( self ) -> bool {
110110 self . get_type ( ) == Some ( NodeType :: TextNode )
111111 }
112112
113113 /// Checks if the given node is an Element
114- pub fn is_element_node ( & self ) -> bool {
114+ pub fn is_element_node ( self ) -> bool {
115115 self . get_type ( ) == Some ( NodeType :: ElementNode )
116116 }
117117
118118 /// Checks if the underlying libxml2 pointer is `NULL`
119- pub fn is_null ( & self ) -> bool {
119+ pub fn is_null ( self ) -> bool {
120120 self . 0 . is_null ( )
121121 }
122122
123123 /// Returns the name of the node (empty string if name pointer is `NULL`)
124- pub fn get_name ( & self ) -> String {
124+ pub fn get_name ( self ) -> String {
125125 let name_ptr = xmlNodeGetName ( self . 0 ) ;
126126 if name_ptr. is_null ( ) {
127127 return String :: new ( ) ;
@@ -132,7 +132,7 @@ impl RoNode {
132132
133133 /// Returns the content of the node
134134 /// (assumes UTF-8 XML document)
135- pub fn get_content ( & self ) -> String {
135+ pub fn get_content ( self ) -> String {
136136 let content_ptr = unsafe { xmlNodeGetContent ( self . 0 ) } ;
137137 if content_ptr. is_null ( ) {
138138 //empty string when none
@@ -147,7 +147,7 @@ impl RoNode {
147147 }
148148
149149 /// Returns the value of property `name`
150- pub fn get_property ( & self , name : & str ) -> Option < String > {
150+ pub fn get_property ( self , name : & str ) -> Option < String > {
151151 let c_name = CString :: new ( name) . unwrap ( ) ;
152152 let value_ptr = unsafe { xmlGetProp ( self . 0 , c_name. as_bytes ( ) . as_ptr ( ) ) } ;
153153 if value_ptr. is_null ( ) {
@@ -163,7 +163,7 @@ impl RoNode {
163163 }
164164
165165 /// Returns the value of property `name` in namespace `ns`
166- pub fn get_property_ns ( & self , name : & str , ns : & str ) -> Option < String > {
166+ pub fn get_property_ns ( self , name : & str , ns : & str ) -> Option < String > {
167167 let c_name = CString :: new ( name) . unwrap ( ) ;
168168 let c_ns = CString :: new ( ns) . unwrap ( ) ;
169169 let value_ptr =
@@ -180,7 +180,7 @@ impl RoNode {
180180 }
181181
182182 /// Return an attribute as a `Node` struct of type AttributeNode
183- pub fn get_property_node ( & self , name : & str ) -> Option < RoNode > {
183+ pub fn get_property_node ( self , name : & str ) -> Option < RoNode > {
184184 let c_name = CString :: new ( name) . unwrap ( ) ;
185185 unsafe {
186186 let attr_node = xmlHasProp ( self . 0 , c_name. as_bytes ( ) . as_ptr ( ) ) ;
@@ -189,21 +189,21 @@ impl RoNode {
189189 }
190190
191191 /// Alias for get_property
192- pub fn get_attribute ( & self , name : & str ) -> Option < String > {
192+ pub fn get_attribute ( self , name : & str ) -> Option < String > {
193193 self . get_property ( name)
194194 }
195195 /// Alias for get_property_ns
196- pub fn get_attribute_ns ( & self , name : & str , ns : & str ) -> Option < String > {
196+ pub fn get_attribute_ns ( self , name : & str , ns : & str ) -> Option < String > {
197197 self . get_property_ns ( name, ns)
198198 }
199199
200200 /// Alias for get_property_node
201- pub fn get_attribute_node ( & self , name : & str ) -> Option < RoNode > {
201+ pub fn get_attribute_node ( self , name : & str ) -> Option < RoNode > {
202202 self . get_property_node ( name)
203203 }
204204
205205 /// Get a copy of the attributes of this node
206- pub fn get_properties ( & self ) -> HashMap < String , String > {
206+ pub fn get_properties ( self ) -> HashMap < String , String > {
207207 let mut attributes = HashMap :: new ( ) ;
208208 let mut attr_names = Vec :: new ( ) ;
209209 unsafe {
@@ -226,12 +226,12 @@ impl RoNode {
226226 }
227227
228228 /// Alias for `get_properties`
229- pub fn get_attributes ( & self ) -> HashMap < String , String > {
229+ pub fn get_attributes ( self ) -> HashMap < String , String > {
230230 self . get_properties ( )
231231 }
232232
233233 /// Gets the active namespace associated of this node
234- pub fn get_namespace ( & self ) -> Option < Namespace > {
234+ pub fn get_namespace ( self ) -> Option < Namespace > {
235235 let ns_ptr = xmlNodeNs ( self . 0 ) ;
236236 if ns_ptr. is_null ( ) {
237237 None
@@ -241,7 +241,7 @@ impl RoNode {
241241 }
242242
243243 /// Gets a list of namespaces associated with this node
244- pub fn get_namespaces ( & self , doc : & Document ) -> Vec < Namespace > {
244+ pub fn get_namespaces ( self , doc : & Document ) -> Vec < Namespace > {
245245 let list_ptr_raw = unsafe { xmlGetNsList ( doc. doc_ptr ( ) , self . 0 ) } ;
246246 if list_ptr_raw. is_null ( ) {
247247 Vec :: new ( )
@@ -270,7 +270,7 @@ impl RoNode {
270270 }
271271
272272 /// Get a list of namespaces declared with this node
273- pub fn get_namespace_declarations ( & self ) -> Vec < Namespace > {
273+ pub fn get_namespace_declarations ( self ) -> Vec < Namespace > {
274274 if self . get_type ( ) != Some ( NodeType :: ElementNode ) {
275275 // only element nodes can have declarations
276276 return Vec :: new ( ) ;
@@ -287,7 +287,7 @@ impl RoNode {
287287 }
288288
289289 /// Looks up the prefix of a namespace from its URI, basedo around a given `Node`
290- pub fn lookup_namespace_prefix ( & self , href : & str ) -> Option < String > {
290+ pub fn lookup_namespace_prefix ( self , href : & str ) -> Option < String > {
291291 if href. is_empty ( ) {
292292 return None ;
293293 }
@@ -306,7 +306,7 @@ impl RoNode {
306306 }
307307
308308 /// Looks up the uri of a namespace from its prefix, basedo around a given `Node`
309- pub fn lookup_namespace_uri ( & self , prefix : & str ) -> Option < String > {
309+ pub fn lookup_namespace_uri ( self , prefix : & str ) -> Option < String > {
310310 if prefix. is_empty ( ) {
311311 return None ;
312312 }
@@ -328,7 +328,7 @@ impl RoNode {
328328 }
329329
330330 /// Get a set of class names from this node's attributes
331- pub fn get_class_names ( & self ) -> HashSet < String > {
331+ pub fn get_class_names ( self ) -> HashSet < String > {
332332 let mut set = HashSet :: new ( ) ;
333333 if let Some ( value) = self . get_property ( "class" ) {
334334 for n in value. split ( ' ' ) {
@@ -339,18 +339,18 @@ impl RoNode {
339339 }
340340
341341 /// find read-only nodes via xpath, at the specified node and a given document
342- pub fn findnodes ( & self , xpath : & str , owner : & Document ) -> Result < Vec < RoNode > , ( ) > {
342+ pub fn findnodes ( self , xpath : & str , owner : & Document ) -> Result < Vec < RoNode > , ( ) > {
343343 let context = Context :: new ( owner) ?;
344344 let evaluated = context. node_evaluate_readonly ( xpath, self ) ?;
345345 Ok ( evaluated. get_readonly_nodes_as_vec ( ) )
346346 }
347347
348348 /// Read-only nodes are always linked
349- pub fn is_unlinked ( & self ) -> bool {
349+ pub fn is_unlinked ( self ) -> bool {
350350 false
351351 }
352352 /// Read-only nodes only need a null check
353- fn ptr_as_option ( & self , node_ptr : xmlNodePtr ) -> Option < RoNode > {
353+ fn ptr_as_option ( self , node_ptr : xmlNodePtr ) -> Option < RoNode > {
354354 if node_ptr. is_null ( ) {
355355 None
356356 } else {
0 commit comments