Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement FusedIterator for all iterator types #73

Merged
merged 1 commit into from
May 19, 2021
Merged
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
8 changes: 8 additions & 0 deletions src/traverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ macro_rules! impl_node_iterator {
Some(node)
}
}

impl<'a, T> core::iter::FusedIterator for $name<'a, T> {}
};
}

Expand Down Expand Up @@ -124,6 +126,8 @@ impl<'a, T> Iterator for Descendants<'a, T> {
}
}

impl<'a, T> core::iter::FusedIterator for Descendants<'a, T> {}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Indicator if the node is at a start or endpoint of the tree
pub enum NodeEdge {
Expand Down Expand Up @@ -194,6 +198,8 @@ impl<'a, T> Iterator for Traverse<'a, T> {
}
}

impl<'a, T> core::iter::FusedIterator for Traverse<'a, T> {}

#[derive(Clone)]
/// An iterator of the "sides" of a node visited during a depth-first pre-order traversal,
/// where nodes are visited end to start and children are visited in reverse insertion order.
Expand Down Expand Up @@ -247,3 +253,5 @@ impl<'a, T> Iterator for ReverseTraverse<'a, T> {
Some(next)
}
}

impl<'a, T> core::iter::FusedIterator for ReverseTraverse<'a, T> {}