Give global options their own lifetime.
This commit is contained in:
@@ -7,9 +7,11 @@ mod list;
|
||||
mod parser_context;
|
||||
mod parser_with_context;
|
||||
|
||||
pub type RefContext<'b, 'r, 's> = &'b Context<'r, 's>;
|
||||
pub trait ContextMatcher =
|
||||
for<'b, 'r, 's> Fn(RefContext<'b, 'r, 's>, OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>>;
|
||||
pub type RefContext<'b, 'g, 'r, 's> = &'b Context<'g, 'r, 's>;
|
||||
pub trait ContextMatcher = for<'b, 'g, 'r, 's> Fn(
|
||||
RefContext<'b, 'g, 'r, 's>,
|
||||
OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>>;
|
||||
pub type DynContextMatcher<'c> = dyn ContextMatcher + 'c;
|
||||
pub trait Matcher = for<'s> Fn(OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>>;
|
||||
#[allow(dead_code)]
|
||||
|
||||
@@ -134,14 +134,14 @@ impl<'r> std::fmt::Debug for ExitMatcherNode<'r> {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Context<'r, 's> {
|
||||
global_settings: &'s GlobalSettings<'s>,
|
||||
pub struct Context<'g, 'r, 's> {
|
||||
global_settings: &'g GlobalSettings<'g>,
|
||||
tree: List<'r, &'r ContextElement<'r, 's>>,
|
||||
}
|
||||
|
||||
impl<'r, 's> Context<'r, 's> {
|
||||
impl<'g, 'r, 's> Context<'g, 'r, 's> {
|
||||
pub fn new(
|
||||
global_settings: &'s GlobalSettings<'s>,
|
||||
global_settings: &'g GlobalSettings<'g>,
|
||||
tree: List<'r, &'r ContextElement<'r, 's>>,
|
||||
) -> Self {
|
||||
Self {
|
||||
@@ -159,7 +159,7 @@ impl<'r, 's> Context<'r, 's> {
|
||||
self.tree.iter()
|
||||
}
|
||||
|
||||
pub fn iter_context(&'r self) -> Iter<'r, 's> {
|
||||
pub fn iter_context(&'r self) -> Iter<'g, 'r, 's> {
|
||||
Iter {
|
||||
next: self.tree.iter_list(),
|
||||
global_settings: self.global_settings,
|
||||
@@ -225,20 +225,20 @@ impl<'r, 's> Context<'r, 's> {
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn document_end<'b, 'r, 's>(
|
||||
_context: RefContext<'b, 'r, 's>,
|
||||
fn document_end<'b, 'g, 'r, 's>(
|
||||
_context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
eof(input)
|
||||
}
|
||||
|
||||
pub struct Iter<'r, 's> {
|
||||
global_settings: &'s GlobalSettings<'s>,
|
||||
pub struct Iter<'g, 'r, 's> {
|
||||
global_settings: &'g GlobalSettings<'g>,
|
||||
next: super::list::IterList<'r, &'r ContextElement<'r, 's>>,
|
||||
}
|
||||
|
||||
impl<'r, 's> Iterator for Iter<'r, 's> {
|
||||
type Item = Context<'r, 's>;
|
||||
impl<'g, 'r, 's> Iterator for Iter<'g, 'r, 's> {
|
||||
type Item = Context<'g, 'r, 's>;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
let next_tree = self.next.next();
|
||||
|
||||
Reference in New Issue
Block a user