Implement iterator for context.

This commit is contained in:
Tom Alexander
2023-09-02 20:46:17 -04:00
parent 22e9bc991f
commit 0d728510d7
9 changed files with 102 additions and 39 deletions

View File

@@ -14,7 +14,9 @@ use nom::multi::many_till;
use nom::sequence::tuple;
use super::org_source::OrgSource;
use super::Context;
use crate::context::parser_with_context;
use crate::context::ContextElement;
use crate::context::RefContext;
use crate::error::CustomError;
use crate::error::MyError;
use crate::error::Res;
@@ -35,7 +37,10 @@ pub fn in_section<'r, 's, 'x>(context: RefContext<'r, 's>, section_name: &'x str
}
/// Checks if we are currently an immediate child of the given section type
pub fn immediate_in_section<'r, 's, 'x>(context: RefContext<'r, 's>, section_name: &'x str) -> bool {
pub fn immediate_in_section<'r, 's, 'x>(
context: RefContext<'r, 's>,
section_name: &'x str,
) -> bool {
for thing in context.iter() {
match thing.get_data() {
ContextElement::Context(name) if *name == section_name => return true,