Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl<L: Language> SyntaxNode<L> {
self.raw.parent().map(Self::from)
}

pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode<L>> {
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode<L>> + use<L> {
self.raw.ancestors().map(SyntaxNode::from)
}

Expand Down Expand Up @@ -219,7 +219,7 @@ impl<L: Language> SyntaxNode<L> {
self.raw.last_token().map(SyntaxToken::from)
}

pub fn siblings(&self, direction: Direction) -> impl Iterator<Item = SyntaxNode<L>> {
pub fn siblings(&self, direction: Direction) -> impl Iterator<Item = SyntaxNode<L>> + use<L> {
self.raw.siblings(direction).map(SyntaxNode::from)
}

Expand All @@ -230,11 +230,11 @@ impl<L: Language> SyntaxNode<L> {
self.raw.siblings_with_tokens(direction).map(SyntaxElement::from)
}

pub fn descendants(&self) -> impl Iterator<Item = SyntaxNode<L>> {
pub fn descendants(&self) -> impl Iterator<Item = SyntaxNode<L>> + use<L> {
self.raw.descendants().map(SyntaxNode::from)
}

pub fn descendants_with_tokens(&self) -> impl Iterator<Item = SyntaxElement<L>> {
pub fn descendants_with_tokens(&self) -> impl Iterator<Item = SyntaxElement<L>> + use<L> {
self.raw.descendants_with_tokens().map(NodeOrToken::from)
}

Expand Down Expand Up @@ -337,12 +337,12 @@ impl<L: Language> SyntaxToken<L> {

/// Iterator over all the ancestors of this token excluding itself.
#[deprecated = "use `SyntaxToken::parent_ancestors` instead"]
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode<L>> {
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode<L>> + use<L> {
self.parent_ancestors()
}

/// Iterator over all the ancestors of this token excluding itself.
pub fn parent_ancestors(&self) -> impl Iterator<Item = SyntaxNode<L>> {
pub fn parent_ancestors(&self) -> impl Iterator<Item = SyntaxNode<L>> + use<L> {
self.raw.ancestors().map(SyntaxNode::from)
}

Expand All @@ -356,7 +356,7 @@ impl<L: Language> SyntaxToken<L> {
pub fn siblings_with_tokens(
&self,
direction: Direction,
) -> impl Iterator<Item = SyntaxElement<L>> {
) -> impl Iterator<Item = SyntaxElement<L>> + use<L> {
self.raw.siblings_with_tokens(direction).map(SyntaxElement::from)
}

Expand Down Expand Up @@ -403,7 +403,7 @@ impl<L: Language> SyntaxElement<L> {
}
}

pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode<L>> {
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode<L>> + use<L> {
let first = match self {
NodeOrToken::Node(it) => Some(it.clone()),
NodeOrToken::Token(it) => it.parent(),
Expand Down
16 changes: 8 additions & 8 deletions src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ impl SyntaxNode {
}

#[inline]
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode> {
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode> + use<> {
iter::successors(Some(self.clone()), SyntaxNode::parent)
}

Expand Down Expand Up @@ -831,7 +831,7 @@ impl SyntaxNode {
}

#[inline]
pub fn siblings(&self, direction: Direction) -> impl Iterator<Item = SyntaxNode> {
pub fn siblings(&self, direction: Direction) -> impl Iterator<Item = SyntaxNode> + use<> {
iter::successors(Some(self.clone()), move |node| match direction {
Direction::Next => node.next_sibling(),
Direction::Prev => node.prev_sibling(),
Expand All @@ -842,7 +842,7 @@ impl SyntaxNode {
pub fn siblings_with_tokens(
&self,
direction: Direction,
) -> impl Iterator<Item = SyntaxElement> {
) -> impl Iterator<Item = SyntaxElement> + use<> {
let me: SyntaxElement = self.clone().into();
iter::successors(Some(me), move |el| match direction {
Direction::Next => el.next_sibling_or_token(),
Expand All @@ -851,15 +851,15 @@ impl SyntaxNode {
}

#[inline]
pub fn descendants(&self) -> impl Iterator<Item = SyntaxNode> {
pub fn descendants(&self) -> impl Iterator<Item = SyntaxNode> + use<> {
self.preorder().filter_map(|event| match event {
WalkEvent::Enter(node) => Some(node),
WalkEvent::Leave(_) => None,
})
}

#[inline]
pub fn descendants_with_tokens(&self) -> impl Iterator<Item = SyntaxElement> {
pub fn descendants_with_tokens(&self) -> impl Iterator<Item = SyntaxElement> + use<> {
self.preorder_with_tokens().filter_map(|event| match event {
WalkEvent::Enter(it) => Some(it),
WalkEvent::Leave(_) => None,
Expand Down Expand Up @@ -1054,7 +1054,7 @@ impl SyntaxToken {
}

#[inline]
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode> {
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode> + use<> {
std::iter::successors(self.parent(), SyntaxNode::parent)
}

Expand All @@ -1077,7 +1077,7 @@ impl SyntaxToken {
pub fn siblings_with_tokens(
&self,
direction: Direction,
) -> impl Iterator<Item = SyntaxElement> {
) -> impl Iterator<Item = SyntaxElement> + use<> {
let me: SyntaxElement = self.clone().into();
iter::successors(Some(me), move |el| match direction {
Direction::Next => el.next_sibling_or_token(),
Expand Down Expand Up @@ -1156,7 +1156,7 @@ impl SyntaxElement {
}

#[inline]
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode> {
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode> + use<> {
let first = match self {
NodeOrToken::Node(it) => Some(it.clone()),
NodeOrToken::Token(it) => it.parent(),
Expand Down
2 changes: 1 addition & 1 deletion src/syntax_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl SyntaxText {
}
}

fn tokens_with_ranges(&self) -> impl Iterator<Item = (SyntaxToken, TextRange)> {
fn tokens_with_ranges(&self) -> impl Iterator<Item = (SyntaxToken, TextRange)> + use<> {
let text_range = self.range;
self.node.descendants_with_tokens().filter_map(|element| element.into_token()).filter_map(
move |token| {
Expand Down
Loading