properly wrap Vec's IntoIter property

This commit is contained in:
Matthew Piziak 2016-08-08 18:21:57 -04:00
parent b1b5526cf0
commit 79630e0cd1

View file

@ -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>,
yaml: vec::IntoIter<Yaml>,
}
impl Iterator for YamlIter {
type Item = Yaml;
fn next(&mut self) -> Option<Yaml> {
self.yaml.pop()
self.yaml.next()
}
}