From 79630e0cd1155ecb0c70e845d1fc813ee914aa67 Mon Sep 17 00:00:00 2001 From: Matthew Piziak Date: Mon, 8 Aug 2016 18:21:57 -0400 Subject: [PATCH] properly wrap Vec's IntoIter property --- parser/src/yaml.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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() } }