@@ -101,22 +101,22 @@ pub enum NodeData {
101101#[ derive( Clone , Debug ) ]
102102pub struct DocumentType {
103103 pub name : StrTendril ,
104- _priv : ( )
104+ _priv : ( ) ,
105105}
106106
107107/// Processing instruction details.
108108#[ derive( Clone , Debug ) ]
109109pub struct ProcessingInstruction {
110110 pub data : StrTendril ,
111- _priv : ( )
111+ _priv : ( ) ,
112112}
113113
114114/// A markup element with name and attributes.
115115#[ derive( Clone , Debug ) ]
116116pub struct Element {
117117 pub name : QualName ,
118118 pub attrs : Vec < Attribute > ,
119- _priv : ( )
119+ _priv : ( ) ,
120120}
121121
122122/// Core implementation.
@@ -133,8 +133,8 @@ impl Document {
133133 /// specified capacity.
134134 pub fn with_capacity ( count : u32 ) -> Self {
135135 let mut nodes = Vec :: with_capacity ( count as usize ) ;
136- nodes. push ( Node :: new ( NodeData :: Hole ) ) ; // Index 0: Padding
137- nodes. push ( Node :: new ( NodeData :: Document ) ) ; // Index 1: DOCUMENT_NODE_ID
136+ nodes. push ( Node :: new ( NodeData :: Hole ) ) ; // Index 0: Padding
137+ nodes. push ( Node :: new ( NodeData :: Document ) ) ; // Index 1: DOCUMENT_NODE_ID
138138 Document { nodes }
139139 }
140140
@@ -164,18 +164,21 @@ impl Document {
164164 pub fn root_element ( & self ) -> Option < NodeId > {
165165 let document_node = & self [ Document :: DOCUMENT_NODE_ID ] ;
166166 debug_assert ! (
167- ( if let NodeData :: Document = document_node. data { true }
168- else { false } ) ,
169- "not document node: {:?}" , document_node) ;
167+ ( if let NodeData :: Document = document_node. data {
168+ true
169+ } else {
170+ false
171+ } ) ,
172+ "not document node: {:?}" ,
173+ document_node
174+ ) ;
170175 debug_assert ! ( document_node. parent. is_none( ) ) ;
171176 debug_assert ! ( document_node. next_sibling. is_none( ) ) ;
172177 debug_assert ! ( document_node. prev_sibling. is_none( ) ) ;
173178 let mut root = None ;
174179 for child in self . children ( Document :: DOCUMENT_NODE_ID ) {
175180 match & self [ child] . data {
176- NodeData :: DocType ( _) |
177- NodeData :: Comment ( _) |
178- NodeData :: Pi ( _) => { }
181+ NodeData :: DocType ( _) | NodeData :: Comment ( _) | NodeData :: Pi ( _) => { }
179182 NodeData :: Document => {
180183 debug_assert ! ( false , "Document child of Document" ) ;
181184 root = None ;
@@ -205,10 +208,17 @@ impl Document {
205208
206209 fn push_node ( & mut self , node : Node ) -> NodeId {
207210 debug_assert ! (
208- ( if let NodeData :: Document | NodeData :: Hole = node. data { false }
209- else { true } ) ,
210- "Invalid push {:?}" , node. data) ;
211- let next_index = self . nodes . len ( )
211+ ( if let NodeData :: Document | NodeData :: Hole = node. data {
212+ false
213+ } else {
214+ true
215+ } ) ,
216+ "Invalid push {:?}" ,
217+ node. data
218+ ) ;
219+ let next_index = self
220+ . nodes
221+ . len ( )
212222 . try_into ( )
213223 . expect ( "Document (u32) node index overflow" ) ;
214224 debug_assert ! ( next_index > 1 ) ;
@@ -283,7 +293,8 @@ impl Document {
283293
284294 fn insert_before ( & mut self , sibling : NodeId , new_sibling : NodeId ) {
285295 self . detach ( new_sibling) ;
286- let parent = self [ sibling] . parent
296+ let parent = self [ sibling]
297+ . parent
287298 . expect ( "insert_before sibling has parent" ) ;
288299 self [ parent] . assert_suitable_parent ( ) ;
289300 self [ new_sibling] . parent = Some ( parent) ;
@@ -370,7 +381,8 @@ impl Document {
370381 push_if_pair (
371382 & mut next,
372383 self [ Document :: DOCUMENT_NODE_ID ] . first_child ,
373- Document :: DOCUMENT_NODE_ID ) ;
384+ Document :: DOCUMENT_NODE_ID ,
385+ ) ;
374386
375387 while let Some ( ( id, nid) ) = next. pop ( ) {
376388 let data = mem:: replace ( & mut self [ id] . data , NodeData :: Hole ) ;
@@ -414,7 +426,9 @@ impl Document {
414426 /// same as the original. As compared with `deep_clone(DOCUMENT_NODE_ID)`
415427 /// this is faster but potentially much less memory efficient.
416428 pub fn bulk_clone ( & self ) -> Document {
417- Document { nodes : self . nodes . clone ( ) }
429+ Document {
430+ nodes : self . nodes . clone ( ) ,
431+ }
418432 }
419433
420434 /// Replace the specified node ID with its children.
@@ -481,7 +495,7 @@ impl Element {
481495 Element {
482496 name : QualName :: new ( None , ns ! ( ) , lname. into ( ) ) ,
483497 attrs : Vec :: new ( ) ,
484- _priv : ( )
498+ _priv : ( ) ,
485499 }
486500 }
487501
@@ -688,9 +702,14 @@ impl NodeData {
688702 #[ inline]
689703 fn assert_suitable_parent ( & self ) {
690704 debug_assert ! (
691- ( if let NodeData :: Document | NodeData :: Elem ( _) = self { true }
692- else { false } ) ,
693- "Not a suitable parent: {:?}" , self )
705+ ( if let NodeData :: Document | NodeData :: Elem ( _) = self {
706+ true
707+ } else {
708+ false
709+ } ) ,
710+ "Not a suitable parent: {:?}" ,
711+ self
712+ )
694713 }
695714}
696715
@@ -700,11 +719,7 @@ fn push_if(stack: &mut Vec<NodeId>, id: Option<NodeId>) {
700719 }
701720}
702721
703- fn push_if_pair (
704- stack : & mut Vec < ( NodeId , NodeId ) > ,
705- id : Option < NodeId > ,
706- oid : NodeId )
707- {
722+ fn push_if_pair ( stack : & mut Vec < ( NodeId , NodeId ) > , id : Option < NodeId > , oid : NodeId ) {
708723 if let Some ( id) = id {
709724 stack. push ( ( id, oid) ) ;
710725 }
0 commit comments