refacotr(orgize): remove more anonymous lifetimes

This commit is contained in:
PoiScript 2019-10-09 15:56:25 +08:00
parent 0c76fd80f6
commit 5d26466e07
21 changed files with 46 additions and 58 deletions

View file

@ -171,7 +171,7 @@ pub fn parse_block_element(input: &str) -> Option<(&str, (&str, Option<&str>, &s
#[inline] #[inline]
fn parse_block_element_internal<'a, E: ParseError<&'a str>>( fn parse_block_element_internal<'a, E: ParseError<&'a str>>(
input: &'a str, input: &'a str,
) -> IResult<&'a str, (&'a str, Option<&'a str>, &'a str), E> { ) -> IResult<&str, (&str, Option<&str>, &str), E> {
let (input, name) = preceded(tag_no_case("#+BEGIN_"), alpha1)(input)?; let (input, name) = preceded(tag_no_case("#+BEGIN_"), alpha1)(input)?;
let (input, args) = line(input)?; let (input, args) = line(input)?;
let end_line = format!("#+END_{}", name); let end_line = format!("#+END_{}", name);

View file

@ -44,7 +44,7 @@ pub enum Clock<'a> {
} }
impl Clock<'_> { impl Clock<'_> {
pub(crate) fn parse(input: &str) -> Option<(&str, Clock<'_>)> { pub(crate) fn parse(input: &str) -> Option<(&str, Clock)> {
parse_clock::<()>(input).ok() parse_clock::<()>(input).ok()
} }
@ -100,7 +100,7 @@ impl Clock<'_> {
} }
/// Constructs a timestamp from the clock. /// Constructs a timestamp from the clock.
pub fn value(&self) -> Timestamp<'_> { pub fn value(&self) -> Timestamp {
match &*self { match &*self {
Clock::Closed { Clock::Closed {
start, start,
@ -127,7 +127,7 @@ impl Clock<'_> {
} }
} }
fn parse_clock<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, Clock<'_>, E> { fn parse_clock<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, Clock, E> {
let (input, _) = tag("CLOCK:")(input)?; let (input, _) = tag("CLOCK:")(input)?;
let (input, _) = space0(input)?; let (input, _) = space0(input)?;
let (input, timestamp) = parse_inactive(input)?; let (input, timestamp) = parse_inactive(input)?;

View file

@ -20,7 +20,7 @@ pub struct Cookie<'a> {
} }
impl Cookie<'_> { impl Cookie<'_> {
pub(crate) fn parse(input: &str) -> Option<(&str, Cookie<'_>)> { pub(crate) fn parse(input: &str) -> Option<(&str, Cookie)> {
parse_cookie::<()>(input).ok() parse_cookie::<()>(input).ok()
} }
@ -32,7 +32,7 @@ impl Cookie<'_> {
} }
#[inline] #[inline]
fn parse_cookie<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, Cookie<'a>, E> { fn parse_cookie<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, Cookie, E> {
let (input, value) = recognize(delimited( let (input, value) = recognize(delimited(
tag("["), tag("["),
alt(( alt((

View file

@ -19,7 +19,7 @@ pub struct Drawer<'a> {
} }
impl Drawer<'_> { impl Drawer<'_> {
pub(crate) fn parse(input: &str) -> Option<(&str, (Drawer<'_>, &str))> { pub(crate) fn parse(input: &str) -> Option<(&str, (Drawer, &str))> {
parse_drawer::<()>(input).ok() parse_drawer::<()>(input).ok()
} }
@ -33,7 +33,7 @@ impl Drawer<'_> {
#[inline] #[inline]
pub fn parse_drawer<'a, E: ParseError<&'a str>>( pub fn parse_drawer<'a, E: ParseError<&'a str>>(
input: &'a str, input: &'a str,
) -> IResult<&'a str, (Drawer<'a>, &'a str), E> { ) -> IResult<&str, (Drawer, &str), E> {
let (input, name) = delimited( let (input, name) = delimited(
tag(":"), tag(":"),
take_while1(|c: char| c.is_ascii_alphabetic() || c == '-' || c == '_'), take_while1(|c: char| c.is_ascii_alphabetic() || c == '-' || c == '_'),

View file

@ -22,7 +22,7 @@ pub struct DynBlock<'a> {
} }
impl DynBlock<'_> { impl DynBlock<'_> {
pub(crate) fn parse(input: &str) -> Option<(&str, (DynBlock<'_>, &str))> { pub(crate) fn parse(input: &str) -> Option<(&str, (DynBlock, &str))> {
parse_dyn_block::<()>(input).ok() parse_dyn_block::<()>(input).ok()
} }
@ -37,7 +37,7 @@ impl DynBlock<'_> {
#[inline] #[inline]
fn parse_dyn_block<'a, E: ParseError<&'a str>>( fn parse_dyn_block<'a, E: ParseError<&'a str>>(
input: &'a str, input: &'a str,
) -> IResult<&'a str, (DynBlock<'a>, &'a str), E> { ) -> IResult<&str, (DynBlock, &str), E> {
let (input, _) = tag_no_case("#+BEGIN:")(input)?; let (input, _) = tag_no_case("#+BEGIN:")(input)?;
let (input, _) = space1(input)?; let (input, _) = space1(input)?;
let (input, name) = alpha1(input)?; let (input, name) = alpha1(input)?;

View file

@ -19,7 +19,7 @@ pub struct FnDef<'a> {
} }
impl FnDef<'_> { impl FnDef<'_> {
pub(crate) fn parse(input: &str) -> Option<(&str, (FnDef<'_>, &str))> { pub(crate) fn parse(input: &str) -> Option<(&str, (FnDef, &str))> {
parse_fn_def::<()>(input).ok() parse_fn_def::<()>(input).ok()
} }
@ -31,9 +31,7 @@ impl FnDef<'_> {
} }
#[inline] #[inline]
fn parse_fn_def<'a, E: ParseError<&'a str>>( fn parse_fn_def<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, (FnDef, &str), E> {
input: &'a str,
) -> IResult<&'a str, (FnDef<'a>, &'a str), E> {
let (input, label) = delimited( let (input, label) = delimited(
tag("[fn:"), tag("[fn:"),
take_while1(|c: char| c.is_ascii_alphanumeric() || c == '-' || c == '_'), take_while1(|c: char| c.is_ascii_alphanumeric() || c == '-' || c == '_'),

View file

@ -21,7 +21,7 @@ pub struct FnRef<'a> {
} }
impl FnRef<'_> { impl FnRef<'_> {
pub(crate) fn parse(input: &str) -> Option<(&str, FnRef<'_>)> { pub(crate) fn parse(input: &str) -> Option<(&str, FnRef)> {
parse_fn_ref::<()>(input).ok() parse_fn_ref::<()>(input).ok()
} }
@ -34,7 +34,7 @@ impl FnRef<'_> {
} }
#[inline] #[inline]
fn parse_fn_ref<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, FnRef<'a>, E> { fn parse_fn_ref<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, FnRef, E> {
let (input, _) = tag("[fn:")(input)?; let (input, _) = tag("[fn:")(input)?;
let (input, label) = let (input, label) =
take_while(|c: char| c.is_ascii_alphanumeric() || c == '-' || c == '_')(input)?; take_while(|c: char| c.is_ascii_alphanumeric() || c == '-' || c == '_')(input)?;
@ -50,7 +50,7 @@ fn parse_fn_ref<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&'a str,
)) ))
} }
fn balanced_brackets<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, &'a str, E> { fn balanced_brackets<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, &str, E> {
let mut pairs = 1; let mut pairs = 1;
for i in memchr2_iter(b'[', b']', input.as_bytes()) { for i in memchr2_iter(b'[', b']', input.as_bytes()) {
if input.as_bytes()[i] == b'[' { if input.as_bytes()[i] == b'[' {

View file

@ -26,7 +26,7 @@ pub struct InlineCall<'a> {
} }
impl InlineCall<'_> { impl InlineCall<'_> {
pub(crate) fn parse(input: &str) -> Option<(&str, InlineCall<'_>)> { pub(crate) fn parse(input: &str) -> Option<(&str, InlineCall)> {
parse_inline_call::<()>(input).ok() parse_inline_call::<()>(input).ok()
} }
@ -41,9 +41,7 @@ impl InlineCall<'_> {
} }
#[inline] #[inline]
fn parse_inline_call<'a, E: ParseError<&'a str>>( fn parse_inline_call<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, InlineCall, E> {
input: &'a str,
) -> IResult<&'a str, InlineCall<'a>, E> {
let (input, name) = preceded( let (input, name) = preceded(
tag("call_"), tag("call_"),
take_till(|c| c == '[' || c == '\n' || c == '(' || c == ')'), take_till(|c| c == '[' || c == '\n' || c == '(' || c == ')'),

View file

@ -23,7 +23,7 @@ pub struct InlineSrc<'a> {
} }
impl InlineSrc<'_> { impl InlineSrc<'_> {
pub(crate) fn parse(input: &str) -> Option<(&str, InlineSrc<'_>)> { pub(crate) fn parse(input: &str) -> Option<(&str, InlineSrc)> {
parse_inline_src::<()>(input).ok() parse_inline_src::<()>(input).ok()
} }
@ -37,9 +37,7 @@ impl InlineSrc<'_> {
} }
#[inline] #[inline]
fn parse_inline_src<'a, E: ParseError<&'a str>>( fn parse_inline_src<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, InlineSrc, E> {
input: &'a str,
) -> IResult<&'a str, InlineSrc<'a>, E> {
let (input, _) = tag("src_")(input)?; let (input, _) = tag("src_")(input)?;
let (input, lang) = let (input, lang) =
take_while1(|c: char| !c.is_ascii_whitespace() && c != '[' && c != '{')(input)?; take_while1(|c: char| !c.is_ascii_whitespace() && c != '[' && c != '{')(input)?;

View file

@ -57,7 +57,7 @@ pub fn parse_keyword(input: &str) -> Option<(&str, (&str, Option<&str>, &str))>
#[inline] #[inline]
fn parse_keyword_internal<'a, E: ParseError<&'a str>>( fn parse_keyword_internal<'a, E: ParseError<&'a str>>(
input: &'a str, input: &'a str,
) -> IResult<&'a str, (&'a str, Option<&'a str>, &'a str), E> { ) -> IResult<&str, (&str, Option<&str>, &str), E> {
let (input, _) = tag("#+")(input)?; let (input, _) = tag("#+")(input)?;
let (input, key) = take_till(|c: char| c.is_ascii_whitespace() || c == ':' || c == '[')(input)?; let (input, key) = take_till(|c: char| c.is_ascii_whitespace() || c == ':' || c == '[')(input)?;
let (input, optional) = opt(delimited( let (input, optional) = opt(delimited(

View file

@ -21,7 +21,7 @@ pub struct Link<'a> {
impl Link<'_> { impl Link<'_> {
#[inline] #[inline]
pub(crate) fn parse(input: &str) -> Option<(&str, Link<'_>)> { pub(crate) fn parse(input: &str) -> Option<(&str, Link)> {
parse_link::<()>(input).ok() parse_link::<()>(input).ok()
} }
@ -34,7 +34,7 @@ impl Link<'_> {
} }
#[inline] #[inline]
fn parse_link<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, Link<'a>, E> { fn parse_link<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, Link, E> {
let (input, path) = delimited( let (input, path) = delimited(
tag("[["), tag("[["),
take_while(|c: char| c != '<' && c != '>' && c != '\n' && c != ']'), take_while(|c: char| c != '<' && c != '>' && c != '\n' && c != ']'),

View file

@ -75,7 +75,7 @@ pub struct ListItem<'a> {
impl ListItem<'_> { impl ListItem<'_> {
#[inline] #[inline]
pub(crate) fn parse(text: &str, indent: usize) -> (&str, ListItem<'_>, &str) { pub(crate) fn parse(text: &str, indent: usize) -> (&str, ListItem, &str) {
debug_assert!(&text[0..indent].trim().is_empty()); debug_assert!(&text[0..indent].trim().is_empty());
let off = &text[indent..].find(' ').unwrap() + 1 + indent; let off = &text[indent..].find(' ').unwrap() + 1 + indent;

View file

@ -21,7 +21,7 @@ pub struct Macros<'a> {
} }
impl Macros<'_> { impl Macros<'_> {
pub(crate) fn parse(input: &str) -> Option<(&str, Macros<'_>)> { pub(crate) fn parse(input: &str) -> Option<(&str, Macros)> {
parse_macros::<()>(input).ok() parse_macros::<()>(input).ok()
} }
@ -34,7 +34,7 @@ impl Macros<'_> {
} }
#[inline] #[inline]
fn parse_macros<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, Macros<'a>, E> { fn parse_macros<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, Macros, E> {
let (input, _) = tag("{{{")(input)?; let (input, _) = tag("{{{")(input)?;
let (input, name) = verify( let (input, name) = verify(
take_while1(|c: char| c.is_ascii_alphanumeric() || c == '-' || c == '_'), take_while1(|c: char| c.is_ascii_alphanumeric() || c == '-' || c == '_'),

View file

@ -20,7 +20,7 @@ pub struct Planning<'a> {
impl Planning<'_> { impl Planning<'_> {
#[inline] #[inline]
pub(crate) fn parse(text: &str) -> Option<(&str, Planning<'_>)> { pub(crate) fn parse(text: &str) -> Option<(&str, Planning)> {
let (mut deadline, mut scheduled, mut closed) = (None, None, None); let (mut deadline, mut scheduled, mut closed) = (None, None, None);
let (mut tail, off) = memchr(b'\n', text.as_bytes()) let (mut tail, off) = memchr(b'\n', text.as_bytes())
.map(|i| (text[..i].trim(), i + 1)) .map(|i| (text[..i].trim(), i + 1))

View file

@ -16,7 +16,7 @@ pub fn parse_radio_target(input: &str) -> Option<(&str, &str)> {
#[inline] #[inline]
fn parse_radio_target_internal<'a, E: ParseError<&'a str>>( fn parse_radio_target_internal<'a, E: ParseError<&'a str>>(
input: &'a str, input: &'a str,
) -> IResult<&'a str, &'a str, E> { ) -> IResult<&str, &str, E> {
let (input, contents) = delimited( let (input, contents) = delimited(
tag("<<<"), tag("<<<"),
verify( verify(

View file

@ -10,7 +10,7 @@ pub fn parse_rule(input: &str) -> Option<&str> {
.map(|(input, _)| input) .map(|(input, _)| input)
} }
fn parse_rule_internal<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, (), E> { fn parse_rule_internal<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, (), E> {
let (input, _) = take_while_m_n(5, usize::MAX, |c| c == '-')(input)?; let (input, _) = take_while_m_n(5, usize::MAX, |c| c == '-')(input)?;
let (input, _) = eol(input)?; let (input, _) = eol(input)?;
Ok((input, ())) Ok((input, ()))

View file

@ -19,7 +19,7 @@ pub struct Snippet<'a> {
} }
impl Snippet<'_> { impl Snippet<'_> {
pub(crate) fn parse(input: &str) -> Option<(&str, Snippet<'_>)> { pub(crate) fn parse(input: &str) -> Option<(&str, Snippet)> {
parse_snippet::<()>(input).ok() parse_snippet::<()>(input).ok()
} }
@ -32,7 +32,7 @@ impl Snippet<'_> {
} }
#[inline] #[inline]
fn parse_snippet<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, Snippet<'a>, E> { fn parse_snippet<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, Snippet, E> {
let (input, (name, value)) = delimited( let (input, (name, value)) = delimited(
tag("@@"), tag("@@"),
separated_pair( separated_pair(

View file

@ -19,7 +19,7 @@ pub struct Target<'a> {
impl Target<'_> { impl Target<'_> {
#[inline] #[inline]
pub(crate) fn parse(input: &str) -> Option<(&str, Target<'_>)> { pub(crate) fn parse(input: &str) -> Option<(&str, Target)> {
parse_target::<()>(input).ok() parse_target::<()>(input).ok()
} }
@ -31,7 +31,7 @@ impl Target<'_> {
} }
#[inline] #[inline]
fn parse_target<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, Target<'a>, E> { fn parse_target<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, Target, E> {
let (input, target) = delimited( let (input, target) = delimited(
tag("<<"), tag("<<"),
verify( verify(

View file

@ -138,15 +138,15 @@ pub enum Timestamp<'a> {
} }
impl Timestamp<'_> { impl Timestamp<'_> {
pub(crate) fn parse_active(input: &str) -> Option<(&str, Timestamp<'_>)> { pub(crate) fn parse_active(input: &str) -> Option<(&str, Timestamp)> {
parse_active::<()>(input).ok() parse_active::<()>(input).ok()
} }
pub(crate) fn parse_inactive(input: &str) -> Option<(&str, Timestamp<'_>)> { pub(crate) fn parse_inactive(input: &str) -> Option<(&str, Timestamp)> {
parse_inactive::<()>(input).ok() parse_inactive::<()>(input).ok()
} }
pub(crate) fn parse_diary(input: &str) -> Option<(&str, Timestamp<'_>)> { pub(crate) fn parse_diary(input: &str) -> Option<(&str, Timestamp)> {
parse_diary::<()>(input).ok() parse_diary::<()>(input).ok()
} }
@ -199,9 +199,7 @@ impl Timestamp<'_> {
} }
} }
pub fn parse_active<'a, E: ParseError<&'a str>>( pub fn parse_active<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, Timestamp, E> {
input: &'a str,
) -> IResult<&'a str, Timestamp<'a>, E> {
let (input, _) = tag("<")(input)?; let (input, _) = tag("<")(input)?;
let (input, start) = parse_datetime(input)?; let (input, start) = parse_datetime(input)?;
@ -254,9 +252,7 @@ pub fn parse_active<'a, E: ParseError<&'a str>>(
} }
} }
pub fn parse_inactive<'a, E: ParseError<&'a str>>( pub fn parse_inactive<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, Timestamp, E> {
input: &'a str,
) -> IResult<&'a str, Timestamp<'a>, E> {
let (input, _) = tag("[")(input)?; let (input, _) = tag("[")(input)?;
let (input, start) = parse_datetime(input)?; let (input, start) = parse_datetime(input)?;
@ -309,9 +305,7 @@ pub fn parse_inactive<'a, E: ParseError<&'a str>>(
} }
} }
pub fn parse_diary<'a, E: ParseError<&'a str>>( pub fn parse_diary<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, Timestamp, E> {
input: &'a str,
) -> IResult<&'a str, Timestamp<'a>, E> {
let (input, _) = tag("<%%(")(input)?; let (input, _) = tag("<%%(")(input)?;
let (input, value) = take_till(|c| c == ')' || c == '>' || c == '\n')(input)?; let (input, value) = take_till(|c| c == ')' || c == '>' || c == '\n')(input)?;
let (input, _) = tag(")>")(input)?; let (input, _) = tag(")>")(input)?;
@ -324,7 +318,7 @@ pub fn parse_diary<'a, E: ParseError<&'a str>>(
)) ))
} }
fn parse_time<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, (u8, u8), E> { fn parse_time<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, (u8, u8), E> {
let (input, hour) = map_res(take_while_m_n(1, 2, |c: char| c.is_ascii_digit()), |num| { let (input, hour) = map_res(take_while_m_n(1, 2, |c: char| c.is_ascii_digit()), |num| {
u8::from_str_radix(num, 10) u8::from_str_radix(num, 10)
})(input)?; })(input)?;
@ -333,7 +327,7 @@ fn parse_time<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, (u
Ok((input, (hour, minute))) Ok((input, (hour, minute)))
} }
fn parse_datetime<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, Datetime<'a>, E> { fn parse_datetime<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, Datetime, E> {
let parse_u8 = |num| u8::from_str_radix(num, 10); let parse_u8 = |num| u8::from_str_radix(num, 10);
let (input, year) = map_res(take(4usize), |num| u16::from_str_radix(num, 10))(input)?; let (input, year) = map_res(take(4usize), |num| u16::from_str_radix(num, 10))(input)?;

View file

@ -185,7 +185,7 @@ fn parse_title<'a, E: ParseError<&'a str>>(
#[inline] #[inline]
fn parse_properties_drawer<'a, E: ParseError<&'a str>>( fn parse_properties_drawer<'a, E: ParseError<&'a str>>(
input: &'a str, input: &'a str,
) -> IResult<&'a str, HashMap<Cow<'a, str>, Cow<'a, str>>, E> { ) -> IResult<&str, HashMap<Cow<'_, str>, Cow<'_, str>>, E> {
let (input, (drawer, content)) = parse_drawer(input.trim_start())?; let (input, (drawer, content)) = parse_drawer(input.trim_start())?;
if drawer.name != "PROPERTIES" { if drawer.name != "PROPERTIES" {
return Err(Err::Error(E::from_error_kind(input, ErrorKind::Tag))); return Err(Err::Error(E::from_error_kind(input, ErrorKind::Tag)));
@ -204,7 +204,7 @@ fn parse_properties_drawer<'a, E: ParseError<&'a str>>(
#[inline] #[inline]
fn parse_node_property<'a, E: ParseError<&'a str>>( fn parse_node_property<'a, E: ParseError<&'a str>>(
input: &'a str, input: &'a str,
) -> IResult<&'a str, (&'a str, &'a str), E> { ) -> IResult<&str, (&str, &str), E> {
let input = skip_empty_lines(input).trim_start(); let input = skip_empty_lines(input).trim_start();
let (input, name) = map(delimited(tag(":"), take_until(":"), tag(":")), |s: &str| { let (input, name) = map(delimited(tag(":"), take_until(":"), tag(":")), |s: &str| {
s.trim_end_matches('+') s.trim_end_matches('+')

View file

@ -444,7 +444,7 @@ struct InlinePositions<'a> {
} }
impl InlinePositions<'_> { impl InlinePositions<'_> {
fn new(bytes: &[u8]) -> InlinePositions<'_> { fn new(bytes: &[u8]) -> InlinePositions {
InlinePositions { InlinePositions {
bytes, bytes,
position: 0, position: 0,
@ -670,7 +670,7 @@ pub fn parse_table<'a, T: ElementArena<'a>>(
} }
} }
pub fn line<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, &'a str, E> { pub fn line<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, &str, E> {
if let Some(i) = memchr(b'\n', input.as_bytes()) { if let Some(i) = memchr(b'\n', input.as_bytes()) {
if i > 0 && input.as_bytes()[i - 1] == b'\r' { if i > 0 && input.as_bytes()[i - 1] == b'\r' {
Ok((&input[i + 1..], &input[0..i - 1])) Ok((&input[i + 1..], &input[0..i - 1]))
@ -682,7 +682,7 @@ pub fn line<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, &'a
} }
} }
pub fn eol<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, &'a str, E> { pub fn eol<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, &str, E> {
verify(line, |s: &str| s.trim().is_empty())(input) verify(line, |s: &str| s.trim().is_empty())(input)
} }
@ -751,7 +751,7 @@ pub fn parse_comment(input: &str) -> Option<(&str, &str)> {
} }
} }
pub fn take_one_word<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, &'a str, E> { pub fn take_one_word<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, &str, E> {
take_while1(|c: char| !c.is_ascii_whitespace())(input) take_while1(|c: char| !c.is_ascii_whitespace())(input)
} }