File tree Expand file tree Collapse file tree 1 file changed +7
-18
lines changed
crates/ark/src/lsp/traits Expand file tree Collapse file tree 1 file changed +7
-18
lines changed Original file line number Diff line number Diff line change @@ -221,13 +221,7 @@ impl<'tree> NodeExt for Node<'tree> {
221
221
fn next_siblings ( & self ) -> impl Iterator < Item = Node < ' tree > > {
222
222
let mut cursor = self . walk ( ) ;
223
223
224
- let first = if cursor. goto_next_sibling ( ) {
225
- Some ( cursor. node ( ) )
226
- } else {
227
- None
228
- } ;
229
-
230
- std:: iter:: successors ( first, move |_| {
224
+ std:: iter:: from_fn ( move || {
231
225
if cursor. goto_next_sibling ( ) {
232
226
Some ( cursor. node ( ) )
233
227
} else {
@@ -238,20 +232,15 @@ impl<'tree> NodeExt for Node<'tree> {
238
232
239
233
fn children_of ( node : Node < ' tree > ) -> impl Iterator < Item = Node < ' tree > > {
240
234
let mut cursor = node. walk ( ) ;
241
- let mut first = true ;
235
+ let mut done = !cursor . goto_first_child ( ) ;
242
236
243
237
std:: iter:: from_fn ( move || {
244
- let advanced = if first {
245
- first = false ;
246
- cursor. goto_first_child ( )
247
- } else {
248
- cursor. goto_next_sibling ( )
249
- } ;
250
-
251
- if advanced {
252
- Some ( cursor. node ( ) )
253
- } else {
238
+ if done {
254
239
None
240
+ } else {
241
+ let item = Some ( cursor. node ( ) ) ;
242
+ done = !cursor. goto_next_sibling ( ) ;
243
+ item
255
244
}
256
245
} )
257
246
}
You can’t perform that action at this time.
0 commit comments