Implement ExactSizeIterator for the other node types.
This commit is contained in:
@@ -11,8 +11,15 @@ macro_rules! children_iter {
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
self.next.next().map(Into::<AstNode>::into)
|
||||
}
|
||||
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
let size = self.next.len();
|
||||
(size, Some(size))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'r, 's> ExactSizeIterator for $itertype<'r, 's> {}
|
||||
|
||||
impl<'r, 's> IntoIterator for &'r $astnodetype {
|
||||
type Item = AstNode<'r, 's>;
|
||||
|
||||
@@ -42,8 +49,14 @@ macro_rules! empty_iter {
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
None
|
||||
}
|
||||
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
(0, Some(0))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'r, 's> ExactSizeIterator for $itertype<'r, 's> {}
|
||||
|
||||
impl<'r, 's> IntoIterator for &'r $astnodetype {
|
||||
type Item = AstNode<'r, 's>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user