diff --git a/orgize/src/elements/block.rs b/orgize/src/elements/block.rs index fc0a011..acc5610 100644 --- a/orgize/src/elements/block.rs +++ b/orgize/src/elements/block.rs @@ -171,7 +171,7 @@ pub fn parse_block_element(input: &str) -> Option<(&str, (&str, Option<&str>, &s #[inline] fn parse_block_element_internal<'a, E: ParseError<&'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, args) = line(input)?; let end_line = format!("#+END_{}", name); diff --git a/orgize/src/elements/clock.rs b/orgize/src/elements/clock.rs index 054bfee..032e314 100644 --- a/orgize/src/elements/clock.rs +++ b/orgize/src/elements/clock.rs @@ -44,7 +44,7 @@ pub enum Clock<'a> { } impl Clock<'_> { - pub(crate) fn parse(input: &str) -> Option<(&str, Clock<'_>)> { + pub(crate) fn parse(input: &str) -> Option<(&str, Clock)> { parse_clock::<()>(input).ok() } @@ -100,7 +100,7 @@ impl Clock<'_> { } /// Constructs a timestamp from the clock. - pub fn value(&self) -> Timestamp<'_> { + pub fn value(&self) -> Timestamp { match &*self { Clock::Closed { 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, _) = space0(input)?; let (input, timestamp) = parse_inactive(input)?; diff --git a/orgize/src/elements/cookie.rs b/orgize/src/elements/cookie.rs index 6cb1ce0..0e0b844 100644 --- a/orgize/src/elements/cookie.rs +++ b/orgize/src/elements/cookie.rs @@ -20,7 +20,7 @@ pub struct Cookie<'a> { } impl Cookie<'_> { - pub(crate) fn parse(input: &str) -> Option<(&str, Cookie<'_>)> { + pub(crate) fn parse(input: &str) -> Option<(&str, Cookie)> { parse_cookie::<()>(input).ok() } @@ -32,7 +32,7 @@ impl Cookie<'_> { } #[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( tag("["), alt(( diff --git a/orgize/src/elements/drawer.rs b/orgize/src/elements/drawer.rs index 0a7b325..033303a 100644 --- a/orgize/src/elements/drawer.rs +++ b/orgize/src/elements/drawer.rs @@ -19,7 +19,7 @@ pub struct Drawer<'a> { } 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() } @@ -33,7 +33,7 @@ impl Drawer<'_> { #[inline] pub fn parse_drawer<'a, E: ParseError<&'a str>>( input: &'a str, -) -> IResult<&'a str, (Drawer<'a>, &'a str), E> { +) -> IResult<&str, (Drawer, &str), E> { let (input, name) = delimited( tag(":"), take_while1(|c: char| c.is_ascii_alphabetic() || c == '-' || c == '_'), diff --git a/orgize/src/elements/dyn_block.rs b/orgize/src/elements/dyn_block.rs index 4afe1c3..a27052c 100644 --- a/orgize/src/elements/dyn_block.rs +++ b/orgize/src/elements/dyn_block.rs @@ -22,7 +22,7 @@ pub struct DynBlock<'a> { } 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() } @@ -37,7 +37,7 @@ impl DynBlock<'_> { #[inline] fn parse_dyn_block<'a, E: ParseError<&'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, _) = space1(input)?; let (input, name) = alpha1(input)?; diff --git a/orgize/src/elements/fn_def.rs b/orgize/src/elements/fn_def.rs index 7a1934c..a3a085e 100644 --- a/orgize/src/elements/fn_def.rs +++ b/orgize/src/elements/fn_def.rs @@ -19,7 +19,7 @@ pub struct FnDef<'a> { } 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() } @@ -31,9 +31,7 @@ impl FnDef<'_> { } #[inline] -fn parse_fn_def<'a, E: ParseError<&'a str>>( - input: &'a str, -) -> IResult<&'a str, (FnDef<'a>, &'a str), E> { +fn parse_fn_def<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, (FnDef, &str), E> { let (input, label) = delimited( tag("[fn:"), take_while1(|c: char| c.is_ascii_alphanumeric() || c == '-' || c == '_'), diff --git a/orgize/src/elements/fn_ref.rs b/orgize/src/elements/fn_ref.rs index 87c5943..90e7a00 100644 --- a/orgize/src/elements/fn_ref.rs +++ b/orgize/src/elements/fn_ref.rs @@ -21,7 +21,7 @@ pub struct FnRef<'a> { } 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() } @@ -34,7 +34,7 @@ impl FnRef<'_> { } #[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, label) = 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; for i in memchr2_iter(b'[', b']', input.as_bytes()) { if input.as_bytes()[i] == b'[' { diff --git a/orgize/src/elements/inline_call.rs b/orgize/src/elements/inline_call.rs index a5f0ecc..80b60f6 100644 --- a/orgize/src/elements/inline_call.rs +++ b/orgize/src/elements/inline_call.rs @@ -26,7 +26,7 @@ pub struct InlineCall<'a> { } 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() } @@ -41,9 +41,7 @@ impl InlineCall<'_> { } #[inline] -fn parse_inline_call<'a, E: ParseError<&'a str>>( - input: &'a str, -) -> IResult<&'a str, InlineCall<'a>, E> { +fn parse_inline_call<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, InlineCall, E> { let (input, name) = preceded( tag("call_"), take_till(|c| c == '[' || c == '\n' || c == '(' || c == ')'), diff --git a/orgize/src/elements/inline_src.rs b/orgize/src/elements/inline_src.rs index d03faa8..c5b1328 100644 --- a/orgize/src/elements/inline_src.rs +++ b/orgize/src/elements/inline_src.rs @@ -23,7 +23,7 @@ pub struct InlineSrc<'a> { } 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() } @@ -37,9 +37,7 @@ impl InlineSrc<'_> { } #[inline] -fn parse_inline_src<'a, E: ParseError<&'a str>>( - input: &'a str, -) -> IResult<&'a str, InlineSrc<'a>, E> { +fn parse_inline_src<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, InlineSrc, E> { let (input, _) = tag("src_")(input)?; let (input, lang) = take_while1(|c: char| !c.is_ascii_whitespace() && c != '[' && c != '{')(input)?; diff --git a/orgize/src/elements/keyword.rs b/orgize/src/elements/keyword.rs index 0625284..788c13e 100644 --- a/orgize/src/elements/keyword.rs +++ b/orgize/src/elements/keyword.rs @@ -57,7 +57,7 @@ pub fn parse_keyword(input: &str) -> Option<(&str, (&str, Option<&str>, &str))> #[inline] fn parse_keyword_internal<'a, E: ParseError<&'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, key) = take_till(|c: char| c.is_ascii_whitespace() || c == ':' || c == '[')(input)?; let (input, optional) = opt(delimited( diff --git a/orgize/src/elements/link.rs b/orgize/src/elements/link.rs index 34b3b5b..0c28555 100644 --- a/orgize/src/elements/link.rs +++ b/orgize/src/elements/link.rs @@ -21,7 +21,7 @@ pub struct Link<'a> { impl Link<'_> { #[inline] - pub(crate) fn parse(input: &str) -> Option<(&str, Link<'_>)> { + pub(crate) fn parse(input: &str) -> Option<(&str, Link)> { parse_link::<()>(input).ok() } @@ -34,7 +34,7 @@ impl Link<'_> { } #[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( tag("[["), take_while(|c: char| c != '<' && c != '>' && c != '\n' && c != ']'), diff --git a/orgize/src/elements/list.rs b/orgize/src/elements/list.rs index ed625b0..3ede500 100644 --- a/orgize/src/elements/list.rs +++ b/orgize/src/elements/list.rs @@ -75,7 +75,7 @@ pub struct ListItem<'a> { impl ListItem<'_> { #[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()); let off = &text[indent..].find(' ').unwrap() + 1 + indent; diff --git a/orgize/src/elements/macros.rs b/orgize/src/elements/macros.rs index a5985e7..9c15ca6 100644 --- a/orgize/src/elements/macros.rs +++ b/orgize/src/elements/macros.rs @@ -21,7 +21,7 @@ pub struct Macros<'a> { } impl Macros<'_> { - pub(crate) fn parse(input: &str) -> Option<(&str, Macros<'_>)> { + pub(crate) fn parse(input: &str) -> Option<(&str, Macros)> { parse_macros::<()>(input).ok() } @@ -34,7 +34,7 @@ impl Macros<'_> { } #[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, name) = verify( take_while1(|c: char| c.is_ascii_alphanumeric() || c == '-' || c == '_'), diff --git a/orgize/src/elements/planning.rs b/orgize/src/elements/planning.rs index ddfc61c..d2cf4df 100644 --- a/orgize/src/elements/planning.rs +++ b/orgize/src/elements/planning.rs @@ -20,7 +20,7 @@ pub struct Planning<'a> { impl Planning<'_> { #[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 tail, off) = memchr(b'\n', text.as_bytes()) .map(|i| (text[..i].trim(), i + 1)) diff --git a/orgize/src/elements/radio_target.rs b/orgize/src/elements/radio_target.rs index c5da94c..18bad1f 100644 --- a/orgize/src/elements/radio_target.rs +++ b/orgize/src/elements/radio_target.rs @@ -16,7 +16,7 @@ pub fn parse_radio_target(input: &str) -> Option<(&str, &str)> { #[inline] fn parse_radio_target_internal<'a, E: ParseError<&'a str>>( input: &'a str, -) -> IResult<&'a str, &'a str, E> { +) -> IResult<&str, &str, E> { let (input, contents) = delimited( tag("<<<"), verify( diff --git a/orgize/src/elements/rule.rs b/orgize/src/elements/rule.rs index 26692f2..81d584e 100644 --- a/orgize/src/elements/rule.rs +++ b/orgize/src/elements/rule.rs @@ -10,7 +10,7 @@ pub fn parse_rule(input: &str) -> Option<&str> { .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, _) = eol(input)?; Ok((input, ())) diff --git a/orgize/src/elements/snippet.rs b/orgize/src/elements/snippet.rs index 8280c04..6816660 100644 --- a/orgize/src/elements/snippet.rs +++ b/orgize/src/elements/snippet.rs @@ -19,7 +19,7 @@ pub struct Snippet<'a> { } impl Snippet<'_> { - pub(crate) fn parse(input: &str) -> Option<(&str, Snippet<'_>)> { + pub(crate) fn parse(input: &str) -> Option<(&str, Snippet)> { parse_snippet::<()>(input).ok() } @@ -32,7 +32,7 @@ impl Snippet<'_> { } #[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( tag("@@"), separated_pair( diff --git a/orgize/src/elements/target.rs b/orgize/src/elements/target.rs index ccf235f..428ae69 100644 --- a/orgize/src/elements/target.rs +++ b/orgize/src/elements/target.rs @@ -19,7 +19,7 @@ pub struct Target<'a> { impl Target<'_> { #[inline] - pub(crate) fn parse(input: &str) -> Option<(&str, Target<'_>)> { + pub(crate) fn parse(input: &str) -> Option<(&str, Target)> { parse_target::<()>(input).ok() } @@ -31,7 +31,7 @@ impl Target<'_> { } #[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( tag("<<"), verify( diff --git a/orgize/src/elements/timestamp.rs b/orgize/src/elements/timestamp.rs index a5527dc..8e0c8bc 100644 --- a/orgize/src/elements/timestamp.rs +++ b/orgize/src/elements/timestamp.rs @@ -138,15 +138,15 @@ pub enum Timestamp<'a> { } 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() } - pub(crate) fn parse_inactive(input: &str) -> Option<(&str, Timestamp<'_>)> { + pub(crate) fn parse_inactive(input: &str) -> Option<(&str, Timestamp)> { 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() } @@ -199,9 +199,7 @@ impl Timestamp<'_> { } } -pub fn parse_active<'a, E: ParseError<&'a str>>( - input: &'a str, -) -> IResult<&'a str, Timestamp<'a>, E> { +pub fn parse_active<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, Timestamp, E> { let (input, _) = tag("<")(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>>( - input: &'a str, -) -> IResult<&'a str, Timestamp<'a>, E> { +pub fn parse_inactive<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, Timestamp, E> { let (input, _) = tag("[")(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>>( - input: &'a str, -) -> IResult<&'a str, Timestamp<'a>, E> { +pub fn parse_diary<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, Timestamp, E> { let (input, _) = tag("<%%(")(input)?; let (input, value) = take_till(|c| c == ')' || c == '>' || c == '\n')(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| { u8::from_str_radix(num, 10) })(input)?; @@ -333,7 +327,7 @@ fn parse_time<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, (u 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 (input, year) = map_res(take(4usize), |num| u16::from_str_radix(num, 10))(input)?; diff --git a/orgize/src/elements/title.rs b/orgize/src/elements/title.rs index 405199e..134baf3 100644 --- a/orgize/src/elements/title.rs +++ b/orgize/src/elements/title.rs @@ -185,7 +185,7 @@ fn parse_title<'a, E: ParseError<&'a str>>( #[inline] fn parse_properties_drawer<'a, E: ParseError<&'a str>>( input: &'a str, -) -> IResult<&'a str, HashMap, Cow<'a, str>>, E> { +) -> IResult<&str, HashMap, Cow<'_, str>>, E> { let (input, (drawer, content)) = parse_drawer(input.trim_start())?; if drawer.name != "PROPERTIES" { 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] fn parse_node_property<'a, E: ParseError<&'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, name) = map(delimited(tag(":"), take_until(":"), tag(":")), |s: &str| { s.trim_end_matches('+') diff --git a/orgize/src/parsers.rs b/orgize/src/parsers.rs index 93cf69e..e87f8c8 100644 --- a/orgize/src/parsers.rs +++ b/orgize/src/parsers.rs @@ -444,7 +444,7 @@ struct InlinePositions<'a> { } impl InlinePositions<'_> { - fn new(bytes: &[u8]) -> InlinePositions<'_> { + fn new(bytes: &[u8]) -> InlinePositions { InlinePositions { bytes, 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 i > 0 && input.as_bytes()[i - 1] == b'\r' { 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) } @@ -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) }