Fix iterator order

This commit is contained in:
dalance 2019-10-29 15:38:00 +09:00
parent 4d996a5edd
commit ad9d31f3fe
3 changed files with 8 additions and 1 deletions

View File

@ -4,6 +4,7 @@
* [Changed] SyntaxTree::get_str can take &RefNode
* [Added] unwrap_locate macro
* [Fixed] iterator order
## [v0.2.1](https://github.com/dalance/sv-parser/compare/v0.2.0...v0.2.1) - 2019-10-28

View File

@ -104,7 +104,8 @@ fn impl_node(ast: &DeriveInput) -> TokenStream {
type IntoIter = Iter<'a>;
fn into_iter(self) -> Self::IntoIter {
let nodes: RefNodes = self.into();
let mut nodes: RefNodes = self.into();
nodes.0.reverse();
Iter { next: nodes }
}
}

View File

@ -14,6 +14,11 @@ pub struct Iter<'a> {
}
impl<'a> Iter<'a> {
pub fn new(mut next: RefNodes<'a>) -> Self {
next.0.reverse();
Iter { next }
}
pub fn event(self) -> EventIter<'a> {
let next: NodeEvents = self.next.into();
EventIter { next }