Implement iterator for context.
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user