From 14a483f4c395bb151f6dd3f5a6a98ac8ab850c33 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Fri, 8 Mar 2019 20:56:24 -0800 Subject: [PATCH] Simplify lifetimes in Node::children in the rust bindings --- lib/binding/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/binding/lib.rs b/lib/binding/lib.rs index 1c7a6caf..3703e299 100644 --- a/lib/binding/lib.rs +++ b/lib/binding/lib.rs @@ -469,10 +469,11 @@ impl<'tree> Node<'tree> { unsafe { ffi::ts_node_child_count(self.0) as usize } } - pub fn children<'a>(&'a self) -> impl Iterator> + 'a { + pub fn children(&self) -> impl Iterator> { + let me = self.clone(); (0..self.child_count()) .into_iter() - .map(move |i| self.child(i).unwrap()) + .map(move |i| me.child(i).unwrap()) } pub fn named_child<'a>(&'a self, i: usize) -> Option {