diff --git a/parser/src/yaml.rs b/parser/src/yaml.rs index e5af16f..6ed730d 100644 --- a/parser/src/yaml.rs +++ b/parser/src/yaml.rs @@ -4,6 +4,7 @@ use std::string; use std::i64; use std::str::FromStr; use std::mem; +use std::vec; use parser::*; use scanner::{TScalarStyle, ScanError, TokenType}; @@ -344,21 +345,19 @@ impl IntoIterator for Yaml { type IntoIter = YamlIter; fn into_iter(self) -> Self::IntoIter { - let mut yaml = self.into_vec().unwrap_or(vec![]); - yaml.reverse(); - YamlIter {yaml: yaml} + YamlIter {yaml: self.into_vec().unwrap_or(vec![]).into_iter()} } } pub struct YamlIter { - yaml: Vec, + yaml: vec::IntoIter, } impl Iterator for YamlIter { type Item = Yaml; fn next(&mut self) -> Option { - self.yaml.pop() + self.yaml.next() } }