Replace old iteration with new iteration.

This commit is contained in:
Tom Alexander
2023-09-27 19:36:23 -04:00
parent 8784da5179
commit 9ce042d5b6
3 changed files with 12 additions and 11 deletions

View File

@@ -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();