diff --git a/src/parser/util.rs b/src/parser/util.rs index 4ee8a27c..75744099 100644 --- a/src/parser/util.rs +++ b/src/parser/util.rs @@ -42,9 +42,9 @@ pub(crate) fn in_section<'b, 'g, 'r, 's, 'x>( } /// Checks if we are currently an immediate child of the given section type -pub(crate) fn immediate_in_section<'b, 'g, 'r, 's, 'x>( - context: RefContext<'b, 'g, 'r, 's>, - section_name: &'x str, +pub(crate) fn immediate_in_section( + context: RefContext<'_, '_, '_, '_>, + section_name: &str, ) -> bool { for thing in context.iter() { match thing { @@ -133,7 +133,7 @@ pub(crate) fn start_of_line<'s>(input: OrgSource<'s>) -> Res, ()> Ok((input, ())) } else { Err(nom::Err::Error(CustomError::MyError(MyError( - "Not at start of line".into(), + "Not at start of line", )))) } } @@ -156,7 +156,7 @@ fn _preceded_by_whitespace<'s>( .unwrap_or(allow_start_of_file) { return Err(nom::Err::Error(CustomError::MyError(MyError( - "Must be preceded by a whitespace character.".into(), + "Must be preceded by a whitespace character.", )))); } Ok((input, ())) @@ -198,9 +198,9 @@ pub(crate) fn text_until_exit<'b, 'g, 'r, 's>( #[allow(dead_code)] fn not_yet_implemented() -> Res, ()> { - return Err(nom::Err::Error(CustomError::MyError(MyError( - "Not implemented yet.".into(), - )))); + Err(nom::Err::Error(CustomError::MyError(MyError( + "Not implemented yet.", + )))) } #[allow(dead_code)] @@ -234,29 +234,27 @@ where /// Match single space or tab. /// /// In org-mode syntax, spaces and tabs are often (but not always!) interchangeable. -pub(crate) fn org_space<'s>(input: OrgSource<'s>) -> Res, char> { +pub(crate) fn org_space(input: OrgSource<'_>) -> Res, char> { one_of(" \t")(input) } /// Matches a single space, tab, line ending, or end of file. /// /// In org-mode syntax there are often delimiters that could be any whitespace at all or the end of file. -pub(crate) fn org_space_or_line_ending<'s>( - input: OrgSource<'s>, -) -> Res, OrgSource<'s>> { +pub(crate) fn org_space_or_line_ending(input: OrgSource<'_>) -> Res, OrgSource<'_>> { alt((recognize(org_space), org_line_ending))(input) } /// Match a line break or the end of the file. /// /// In org-mode syntax, the end of the file can serve the same purpose as a line break syntactically. -pub(crate) fn org_line_ending<'s>(input: OrgSource<'s>) -> Res, OrgSource<'s>> { +pub(crate) fn org_line_ending(input: OrgSource<'_>) -> Res, OrgSource<'_>> { alt((line_ending, eof))(input) } /// Match the whitespace at the beginning of a line and give it an indentation level. -pub(crate) fn indentation_level<'b, 'g, 'r, 's>( - context: RefContext<'b, 'g, 'r, 's>, +pub(crate) fn indentation_level<'s>( + context: RefContext<'_, '_, '_, 's>, input: OrgSource<'s>, ) -> Res, (IndentationLevel, OrgSource<'s>)> { let (remaining, leading_whitespace) = space0(input)?; diff --git a/src/types/affiliated_keyword.rs b/src/types/affiliated_keyword.rs index d5f2fd4d..ad9e7fb1 100644 --- a/src/types/affiliated_keyword.rs +++ b/src/types/affiliated_keyword.rs @@ -19,7 +19,7 @@ pub struct AffiliatedKeyword<'s> { pub value: AffiliatedKeywordValue<'s>, } -#[derive(Debug)] +#[derive(Debug, Default)] pub struct AffiliatedKeywords<'s> { pub(crate) keywords: BTreeMap>, } @@ -27,11 +27,3 @@ pub struct AffiliatedKeywords<'s> { pub trait GetAffiliatedKeywords<'s> { fn get_affiliated_keywords<'a>(&'a self) -> &'a AffiliatedKeywords<'s>; } - -impl<'s> Default for AffiliatedKeywords<'s> { - fn default() -> Self { - AffiliatedKeywords { - keywords: BTreeMap::new(), - } - } -} diff --git a/src/types/document.rs b/src/types/document.rs index eacf8583..e6f128c9 100644 --- a/src/types/document.rs +++ b/src/types/document.rs @@ -101,9 +101,8 @@ impl<'s> Heading<'s> { _ => None, }) .flat_map(|section| section.children.iter()) - .take_while(|element| match element { - Element::Planning(_) | Element::PropertyDrawer(_) => true, - _ => false, + .take_while(|element| { + matches!(element, Element::Planning(_) | Element::PropertyDrawer(_)) }) .find_map(|element| match element { Element::PropertyDrawer(property_drawer) => Some(property_drawer), @@ -121,10 +120,8 @@ impl<'s> Document<'s> { .iter() .flat_map(|zeroth_section| zeroth_section.children.iter()); let property_drawer = zeroth_section_children - .take_while(|element| match element { - Element::Comment(_) => true, - Element::PropertyDrawer(_) => true, - _ => false, + .take_while(|element| { + matches!(element, Element::Comment(_) | Element::PropertyDrawer(_)) }) .find_map(|element| match element { Element::PropertyDrawer(property_drawer) => Some(property_drawer),