From 9a1d91ae45576f0f15a142bd63d0358f4c057546 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Wed, 27 Sep 2023 15:17:56 -0400 Subject: [PATCH] Manual implementation of BoldIter. --- src/iter/ast_node_iter.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/iter/ast_node_iter.rs b/src/iter/ast_node_iter.rs index 0ad3093..0abe9d9 100644 --- a/src/iter/ast_node_iter.rs +++ b/src/iter/ast_node_iter.rs @@ -1,4 +1,5 @@ use super::ast_node::AstNode; +use crate::types::Bold; use crate::types::Object; pub enum AstNodeIter<'r, 's> { @@ -67,7 +68,18 @@ impl<'r, 's> Iterator for BoldIter<'r, 's> { type Item = AstNode<'r, 's>; fn next(&mut self) -> Option { - let foo = self.next.next(); - todo!() + self.next.next().map(Into::::into) + } +} + +impl<'r, 's> IntoIterator for &'r Bold<'s> { + type Item = AstNode<'r, 's>; + + type IntoIter = BoldIter<'r, 's>; + + fn into_iter(self) -> Self::IntoIter { + BoldIter { + next: self.children.iter(), + } } }