remove clone from into_iter

This commit is contained in:
Matthew Piziak 2016-08-08 17:52:24 -04:00
parent b600b3bafe
commit 9e77a839d3

View file

@ -344,22 +344,21 @@ impl IntoIterator for Yaml {
type IntoIter = YamlIter;
fn into_iter(self) -> Self::IntoIter {
YamlIter {yaml: self, index: 0}
let mut yaml = self.into_vec().unwrap_or(vec![]);
yaml.reverse();
YamlIter {yaml: yaml}
}
}
pub struct YamlIter {
yaml: Yaml,
index: usize,
yaml: Vec<Yaml>,
}
impl Iterator for YamlIter {
type Item = Yaml;
fn next(&mut self) -> Option<Yaml> {
let result = self.yaml[self.index].clone();
self.index += 1;
Some(result)
self.yaml.pop()
}
}