Give global options their own lifetime.
This commit is contained in:
@@ -17,6 +17,7 @@ use super::util::exit_matcher_parser;
|
||||
use super::util::maybe_consume_object_trailing_whitespace_if_not_exiting;
|
||||
use crate::context::parser_with_context;
|
||||
use crate::context::ContextElement;
|
||||
use crate::context::ContextMatcher;
|
||||
use crate::context::ExitClass;
|
||||
use crate::context::ExitMatcherNode;
|
||||
use crate::context::RefContext;
|
||||
@@ -29,8 +30,8 @@ use crate::types::Subscript;
|
||||
use crate::types::Superscript;
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn subscript<'r, 's>(
|
||||
context: RefContext<'_, 'r, 's>,
|
||||
pub fn subscript<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Subscript<'s>> {
|
||||
// We check for the underscore first before checking the pre-character as a minor optimization to avoid walking up the context tree to find the document root unnecessarily.
|
||||
@@ -49,8 +50,8 @@ pub fn subscript<'r, 's>(
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn superscript<'r, 's>(
|
||||
context: RefContext<'_, 'r, 's>,
|
||||
pub fn superscript<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Superscript<'s>> {
|
||||
// We check for the circumflex first before checking the pre-character as a minor optimization to avoid walking up the context tree to find the document root unnecessarily.
|
||||
@@ -69,7 +70,10 @@ pub fn superscript<'r, 's>(
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn pre<'r, 's>(_context: RefContext<'_, 'r, 's>, input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> {
|
||||
fn pre<'b, 'g, 'r, 's>(
|
||||
_context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, ()> {
|
||||
let preceding_character = input.get_preceding_character();
|
||||
match preceding_character {
|
||||
Some(c) if !c.is_whitespace() => {}
|
||||
@@ -89,8 +93,8 @@ enum ScriptBody<'s> {
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn script_body<'r, 's>(
|
||||
context: RefContext<'_, 'r, 's>,
|
||||
fn script_body<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, ScriptBody<'s>> {
|
||||
alt((
|
||||
@@ -107,16 +111,16 @@ fn script_body<'r, 's>(
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn script_asterisk<'r, 's>(
|
||||
_context: RefContext<'_, 'r, 's>,
|
||||
fn script_asterisk<'b, 'g, 'r, 's>(
|
||||
_context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
tag("*")(input)
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn script_alphanum<'r, 's>(
|
||||
context: RefContext<'_, 'r, 's>,
|
||||
fn script_alphanum<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
let (remaining, _sign) = opt(recognize(one_of("+-")))(input)?;
|
||||
@@ -129,8 +133,8 @@ fn script_alphanum<'r, 's>(
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn script_alphanum_character<'r, 's>(
|
||||
_context: RefContext<'_, 'r, 's>,
|
||||
fn script_alphanum_character<'b, 'g, 'r, 's>(
|
||||
_context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
recognize(verify(anychar, |c| {
|
||||
@@ -139,8 +143,8 @@ fn script_alphanum_character<'r, 's>(
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn end_script_alphanum_character<'r, 's>(
|
||||
context: RefContext<'_, 'r, 's>,
|
||||
fn end_script_alphanum_character<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
let (remaining, final_char) = recognize(verify(anychar, |c| c.is_alphanumeric()))(input)?;
|
||||
@@ -151,8 +155,8 @@ fn end_script_alphanum_character<'r, 's>(
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn script_with_braces<'r, 's>(
|
||||
context: RefContext<'_, 'r, 's>,
|
||||
fn script_with_braces<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Vec<Object<'s>>> {
|
||||
let (remaining, _) = tag("{")(input)?;
|
||||
@@ -172,18 +176,15 @@ fn script_with_braces<'r, 's>(
|
||||
Ok((remaining, children))
|
||||
}
|
||||
|
||||
fn script_with_braces_end(
|
||||
starting_brace_depth: BracketDepth,
|
||||
) -> impl for<'b, 'r, 's> Fn(RefContext<'b, 'r, 's>, OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>>
|
||||
{
|
||||
fn script_with_braces_end(starting_brace_depth: BracketDepth) -> impl ContextMatcher {
|
||||
move |context, input: OrgSource<'_>| {
|
||||
_script_with_braces_end(context, input, starting_brace_depth)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn _script_with_braces_end<'r, 's>(
|
||||
_context: RefContext<'_, 'r, 's>,
|
||||
fn _script_with_braces_end<'b, 'g, 'r, 's>(
|
||||
_context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
starting_brace_depth: BracketDepth,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
|
||||
Reference in New Issue
Block a user