Replace old iteration with new iteration.
This commit is contained in:
		
							parent
							
								
									8784da5179
								
							
						
					
					
						commit
						9ce042d5b6
					
				| @ -69,7 +69,7 @@ use crate::types::VerseBlock; | ||||
| /// This only iterates over the children, not the starting node itself. So an AstNodeIter::PlainList would only return PlainListItems, not the PlainList.
 | ||||
| ///
 | ||||
| /// This only iterates over AST nodes, so an AstNodeIter::Heading would iterate over both the title and section contents, but it would not iterate over simple strings like the TODO keyword or priority.
 | ||||
| pub enum AstNodeIter<'r, 's> { | ||||
| pub(crate) enum AstNodeIter<'r, 's> { | ||||
|     // Document Nodes
 | ||||
|     Document(DocumentIter<'r, 's>), | ||||
|     Heading(HeadingIter<'r, 's>), | ||||
| @ -132,7 +132,7 @@ pub enum AstNodeIter<'r, 's> { | ||||
| } | ||||
| 
 | ||||
| impl<'r, 's> AstNodeIter<'r, 's> { | ||||
|     pub fn from_ast_node(node: &AstNode<'r, 's>) -> AstNodeIter<'r, 's> { | ||||
|     pub(crate) fn from_ast_node(node: &AstNode<'r, 's>) -> AstNodeIter<'r, 's> { | ||||
|         match node { | ||||
|             AstNode::Document(inner) => AstNodeIter::Document(inner.into_iter()), | ||||
|             AstNode::Heading(inner) => AstNodeIter::Heading(inner.into_iter()), | ||||
|  | ||||
| @ -2,3 +2,4 @@ mod all_ast_node_iter; | ||||
| mod ast_node; | ||||
| mod ast_node_iter; | ||||
| mod macros; | ||||
| pub(crate) use ast_node::AstNode; | ||||
|  | ||||
| @ -19,6 +19,7 @@ use crate::context::RefContext; | ||||
| use crate::error::CustomError; | ||||
| use crate::error::MyError; | ||||
| use crate::error::Res; | ||||
| use crate::iter::AstNode; | ||||
| use crate::parser::org_source::convert_error; | ||||
| use crate::parser::util::blank_line; | ||||
| use crate::types::Document; | ||||
| @ -111,15 +112,14 @@ fn document_org_source<'b, 'g, 'r, 's>( | ||||
|         _document(context, input).map(|(rem, out)| (Into::<&str>::into(rem), out))?; | ||||
|     { | ||||
|         // If there are radio targets in this document then we need to parse the entire document again with the knowledge of the radio targets.
 | ||||
|         let all_radio_targets: Vec<&Vec<Object<'_>>> = document | ||||
|             .iter_tokens() | ||||
|             .filter_map(|tkn| match tkn { | ||||
|                 Token::Object(obj) => Some(obj), | ||||
|                 _ => None, | ||||
|             }) | ||||
|             .filter_map(|obj| match obj { | ||||
|                 Object::RadioTarget(rt) => Some(rt), | ||||
|                 _ => None, | ||||
|         let all_radio_targets: Vec<&Vec<Object<'_>>> = Into::<AstNode>::into(&document) | ||||
|             .into_iter() | ||||
|             .filter_map(|ast_node| { | ||||
|                 if let AstNode::RadioTarget(ast_node) = ast_node { | ||||
|                     Some(ast_node) | ||||
|                 } else { | ||||
|                     None | ||||
|                 } | ||||
|             }) | ||||
|             .map(|rt| &rt.children) | ||||
|             .collect(); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander