@@ -92,10 +92,10 @@ impl Node {
9292 if self . name == name {
9393 nodes. push ( self . clone ( ) ) ;
9494 }
95- if let Some ( d) = depth {
96- if d == 0 {
97- return nodes ;
98- }
95+ if let Some ( d) = depth
96+ && d == 0
97+ {
98+ return nodes ;
9999 }
100100 for child in & self . children {
101101 nodes. append ( & mut child. search_by_name ( name, depth. map ( |d| d - 1 ) ) ) ;
@@ -108,10 +108,10 @@ impl Node {
108108 if self . attrs . contains_key ( key) {
109109 nodes. push ( self . clone ( ) ) ;
110110 }
111- if let Some ( d) = depth {
112- if d == 0 {
113- return nodes ;
114- }
111+ if let Some ( d) = depth
112+ && d == 0
113+ {
114+ return nodes ;
115115 }
116116 for child in & self . children {
117117 nodes. append ( & mut child. search_by_attr ( key, depth. map ( |d| d - 1 ) ) ) ;
@@ -121,15 +121,15 @@ impl Node {
121121 #[ pyo3( signature = ( text, depth=None ) ) ]
122122 fn search_by_text ( & self , text : & str , depth : Option < i32 > ) -> Vec < Node > {
123123 let mut nodes = Vec :: new ( ) ;
124- if let Some ( t) = & self . text {
125- if t == text {
126- nodes . push ( self . clone ( ) ) ;
127- }
124+ if let Some ( t) = & self . text
125+ && t == text
126+ {
127+ nodes . push ( self . clone ( ) ) ;
128128 }
129- if let Some ( d) = depth {
130- if d == 0 {
131- return nodes ;
132- }
129+ if let Some ( d) = depth
130+ && d == 0
131+ {
132+ return nodes ;
133133 }
134134 for child in & self . children {
135135 nodes. append ( & mut child. search_by_text ( text, depth. map ( |d| d - 1 ) ) ) ;
0 commit comments