remove clone from into_iter
This commit is contained in:
parent
3adfd05000
commit
b1b5526cf0
1 changed files with 13 additions and 14 deletions
|
@ -344,22 +344,21 @@ impl IntoIterator for Yaml {
|
||||||
type IntoIter = YamlIter;
|
type IntoIter = YamlIter;
|
||||||
|
|
||||||
fn into_iter(self) -> Self::IntoIter {
|
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 {
|
pub struct YamlIter {
|
||||||
yaml: Yaml,
|
yaml: Vec<Yaml>,
|
||||||
index: usize,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Iterator for YamlIter {
|
impl Iterator for YamlIter {
|
||||||
type Item = Yaml;
|
type Item = Yaml;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Yaml> {
|
fn next(&mut self) -> Option<Yaml> {
|
||||||
let result = self.yaml[self.index].clone();
|
self.yaml.pop()
|
||||||
self.index += 1;
|
|
||||||
Some(result)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue