From 50a67c65ef88f9b23cbb79afdaf5997411f2787d Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 18 Dec 2022 03:30:28 -0500 Subject: [PATCH] Standardize order of lifetimes for r and s. --- src/parser/bold.rs | 10 +++++----- src/parser/link.rs | 8 ++++---- src/parser/paragraph.rs | 4 ++-- src/parser/text.rs | 2 +- src/parser/util.rs | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/parser/bold.rs b/src/parser/bold.rs index cc833f84..0da997d8 100644 --- a/src/parser/bold.rs +++ b/src/parser/bold.rs @@ -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() { diff --git a/src/parser/link.rs b/src/parser/link.rs index ce2a7d48..f9e6bc95 100644 --- a/src/parser/link.rs +++ b/src/parser/link.rs @@ -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)) } diff --git a/src/parser/paragraph.rs b/src/parser/paragraph.rs index dc9982df..83a3a970 100644 --- a/src/parser/paragraph.rs +++ b/src/parser/paragraph.rs @@ -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> { diff --git a/src/parser/text.rs b/src/parser/text.rs index e61c4e9f..054e4802 100644 --- a/src/parser/text.rs +++ b/src/parser/text.rs @@ -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); diff --git a/src/parser/util.rs b/src/parser/util.rs index c06fb3ef..44886cea 100644 --- a/src/parser/util.rs +++ b/src/parser/util.rs @@ -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(_) => {}