Standardize order of lifetimes for r and s.

This commit is contained in:
Tom Alexander 2022-12-18 03:30:28 -05:00
parent 2def475337
commit 50a67c65ef
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
5 changed files with 13 additions and 13 deletions

View File

@ -20,7 +20,7 @@ use nom::combinator::peek;
use nom::combinator::recognize;
use nom::sequence::tuple;
pub fn bold<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Bold<'s>> {
pub fn bold<'r, 's>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Bold<'s>> {
let bold_start = parser_with_context!(context_bold_start)(&context);
let parser_context = context
.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
@ -34,11 +34,11 @@ pub fn bold<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Bold<'
Ok((remaining, ret))
}
fn can_start_bold<'s, 'r>(context: Context<'r, 's>) -> bool {
fn can_start_bold<'r, 's>(context: Context<'r, 's>) -> bool {
_preceded_by_whitespace(context) && !in_section(context, "bold")
}
fn context_bold_start<'s, 'r>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
fn context_bold_start<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
if can_start_bold(context) {
recognize(bold_start)(input)
} else {
@ -49,7 +49,7 @@ fn context_bold_start<'s, 'r>(context: Context<'r, 's>, input: &'s str) -> Res<&
}
}
fn context_bold_end<'s, 'r>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
fn context_bold_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
let (remaining, actual_match) = recognize(bold_end)(input)?;
peek(alt((
// Must have whitespace after the end asterisk or it must be the end of that section (as checked by the exit matcher)
@ -70,7 +70,7 @@ fn bold_end(input: &str) -> Res<&str, TextElement> {
map(symbol("*"), TextElement::Symbol)(input)
}
fn _preceded_by_whitespace<'s, 'r>(context: Context<'r, 's>) -> bool {
fn _preceded_by_whitespace<'r, 's>(context: Context<'r, 's>) -> bool {
let mut context_iterator = context.iter().enumerate();
loop {
if let Some((i, ctx)) = context_iterator.next() {

View File

@ -17,7 +17,7 @@ use nom::combinator::map;
use nom::combinator::recognize;
use nom::sequence::tuple;
pub fn link<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Link<'s>> {
pub fn link<'r, 's>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Link<'s>> {
let link_start = parser_with_context!(context_link_start)(&context);
let parser_context = context
.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
@ -31,11 +31,11 @@ pub fn link<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Link<'
Ok((remaining, ret))
}
fn can_start_link<'s, 'r>(context: Context<'r, 's>) -> bool {
fn can_start_link<'r, 's>(context: Context<'r, 's>) -> bool {
!in_section(context, "link")
}
fn context_link_start<'s, 'r>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
fn context_link_start<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
if can_start_link(context) {
recognize(link_start)(input)
} else {
@ -46,7 +46,7 @@ fn context_link_start<'s, 'r>(context: Context<'r, 's>, input: &'s str) -> Res<&
}
}
fn context_link_end<'s, 'r>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
fn context_link_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
let (remaining, actual_match) = recognize(link_end)(input)?;
Ok((remaining, actual_match))
}

View File

@ -18,7 +18,7 @@ use nom::combinator::recognize;
use nom::multi::many1;
use nom::sequence::tuple;
pub fn paragraph<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Paragraph<'s>> {
pub fn paragraph<'r, 's>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Paragraph<'s>> {
// Add a not(eof) check because many_till cannot match a zero-length string
not(eof)(i)?;
let paragraph_context = context
@ -44,7 +44,7 @@ pub fn paragraph<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, P
))
}
fn context_paragraph_end<'s, 'r>(
fn context_paragraph_end<'r, 's>(
context: Context<'r, 's>,
input: &'s str,
) -> Res<&'s str, &'s str> {

View File

@ -49,7 +49,7 @@ pub fn blank_line(input: &str) -> Res<&str, BlankLine> {
)(input)
}
pub fn text_element<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, TextElement<'s>> {
pub fn text_element<'r, 's>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, TextElement<'s>> {
not(|i| context.check_exit_matcher(i))(i)?;
let bold_matcher = parser_with_context!(bold)(&context);

View File

@ -1,7 +1,7 @@
use super::parser_context::ContextElement;
use super::Context;
pub fn in_section<'s, 'r, 'x>(context: Context<'r, 's>, section_name: &'x str) -> bool {
pub fn in_section<'r, 's, 'x>(context: Context<'r, 's>, section_name: &'x str) -> bool {
for thing in context.iter() {
match thing.get_data() {
ContextElement::ExitMatcherNode(_) => {}