From 306971144752c54ae148b981d4c4e665aecec7c3 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 16 Oct 2023 18:29:21 -0400 Subject: [PATCH] Apply more suggestions. --- src/compare/sexp.rs | 9 +++---- src/compare/util.rs | 5 +--- src/context/file_access_interface.rs | 3 +-- src/context/global_settings.rs | 10 +++----- src/context/list.rs | 2 +- src/context/parser_with_context.rs | 2 +- src/error/mod.rs | 1 + src/parser/affiliated_keyword.rs | 21 +++++++-------- src/parser/babel_call.rs | 38 +++++++++++++++------------- src/parser/citation.rs | 3 ++- src/parser/citation_reference.rs | 2 +- src/parser/comment.rs | 5 ++-- src/parser/document.rs | 22 +++++++--------- src/parser/drawer.rs | 2 +- src/parser/dynamic_block.rs | 7 ++--- src/parser/element_parser.rs | 6 ++--- src/parser/entity.rs | 13 +++------- src/parser/footnote_definition.rs | 7 ++--- src/parser/footnote_reference.rs | 2 +- src/parser/greater_block.rs | 12 ++++----- src/parser/headline.rs | 26 ++++++------------- src/parser/inline_babel_call.rs | 2 +- 22 files changed, 86 insertions(+), 114 deletions(-) diff --git a/src/compare/sexp.rs b/src/compare/sexp.rs index 069863a..a6bd577 100644 --- a/src/compare/sexp.rs +++ b/src/compare/sexp.rs @@ -348,10 +348,7 @@ mod tests { let input = r#" (foo "b(a)r" baz ) "#; let (remaining, parsed) = sexp(input).expect("Parse the input"); assert_eq!(remaining, ""); - assert!(match parsed { - Token::List(_) => true, - _ => false, - }); + assert!(matches!(parsed, Token::List(_))); let children = match parsed { Token::List(children) => children, _ => panic!("Should be a list."), @@ -364,14 +361,14 @@ mod tests { r#"foo"# ); assert_eq!( - match children.iter().nth(1) { + match children.get(1) { Some(Token::Atom(body)) => *body, _ => panic!("Second child should be an atom."), }, r#""b(a)r""# ); assert_eq!( - match children.iter().nth(2) { + match children.get(2) { Some(Token::Atom(body)) => *body, _ => panic!("Third child should be an atom."), }, diff --git a/src/compare/util.rs b/src/compare/util.rs index c0a3760..1cb8a8f 100644 --- a/src/compare/util.rs +++ b/src/compare/util.rs @@ -117,10 +117,7 @@ fn get_emacs_standard_properties<'b, 's>( emacs: &'b Token<'s>, ) -> Result> { let children = emacs.as_list()?; - let attributes_child = children - .iter() - .nth(1) - .ok_or("Should have an attributes child.")?; + let attributes_child = children.get(1).ok_or("Should have an attributes child.")?; let attributes_map = attributes_child.as_map()?; let standard_properties = attributes_map.get(":standard-properties"); Ok(if standard_properties.is_some() { diff --git a/src/context/file_access_interface.rs b/src/context/file_access_interface.rs index d269edf..ebc7269 100644 --- a/src/context/file_access_interface.rs +++ b/src/context/file_access_interface.rs @@ -20,8 +20,7 @@ impl FileAccessInterface for LocalFileAccessInterface { fn read_file(&self, path: &str) -> Result { let final_path = self .working_directory - .as_ref() - .map(PathBuf::as_path) + .as_deref() .map(|pb| pb.join(path)) .unwrap_or_else(|| PathBuf::from(path)); Ok(std::fs::read_to_string(final_path)?) diff --git a/src/context/global_settings.rs b/src/context/global_settings.rs index 8a27a68..fa17799 100644 --- a/src/context/global_settings.rs +++ b/src/context/global_settings.rs @@ -126,14 +126,10 @@ impl<'g, 's> Default for GlobalSettings<'g, 's> { } } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Default)] pub enum HeadlineLevelFilter { Odd, + + #[default] OddEven, } - -impl Default for HeadlineLevelFilter { - fn default() -> Self { - HeadlineLevelFilter::OddEven - } -} diff --git a/src/context/list.rs b/src/context/list.rs index 43d8d62..f3191b3 100644 --- a/src/context/list.rs +++ b/src/context/list.rs @@ -64,7 +64,7 @@ impl<'a, T> Iterator for IterList<'a, T> { fn next(&mut self) -> Option { let ret = self.next; - self.next = self.next.map(|this| this.get_parent()).flatten(); + self.next = self.next.and_then(|link| link.get_parent()); ret } } diff --git a/src/context/parser_with_context.rs b/src/context/parser_with_context.rs index 1726707..610f194 100644 --- a/src/context/parser_with_context.rs +++ b/src/context/parser_with_context.rs @@ -7,7 +7,7 @@ pub(crate) use parser_with_context; macro_rules! bind_context { ($target:expr, $context:expr) => { - move |i| $target($context, i) + |i| $target($context, i) }; } pub(crate) use bind_context; diff --git a/src/error/mod.rs b/src/error/mod.rs index 25109b4..23cd35f 100644 --- a/src/error/mod.rs +++ b/src/error/mod.rs @@ -1,3 +1,4 @@ +#[allow(clippy::module_inception)] mod error; pub(crate) use error::CustomError; pub(crate) use error::MyError; diff --git a/src/parser/affiliated_keyword.rs b/src/parser/affiliated_keyword.rs index 485fadc..ded3fa8 100644 --- a/src/parser/affiliated_keyword.rs +++ b/src/parser/affiliated_keyword.rs @@ -16,7 +16,7 @@ use nom::sequence::tuple; use super::object_parser::standard_set_object; use super::util::confine_context; -use crate::context::parser_with_context; +use crate::context::bind_context; use crate::context::Context; use crate::context::ContextElement; use crate::context::GlobalSettings; @@ -64,7 +64,7 @@ where eof, )), |(_, _, objects, _, _)| objects, - )))(kw.key.into()) + )))(kw.key) .expect("Parser should always succeed."); ret.insert( translated_name, @@ -85,8 +85,9 @@ where map_parser( recognize(many_till(anychar, peek(tuple((tag("]"), eof))))), confine_context(|i| { - all_consuming(many0(parser_with_context!(standard_set_object)( - &initial_context, + all_consuming(many0(bind_context!( + standard_set_object, + &initial_context )))(i) }), ), @@ -98,11 +99,11 @@ where .expect("Object parser should always succeed."); // TODO: This should be omitting footnote references - let (_remaining, objects) = - all_consuming(many0(parser_with_context!(standard_set_object)( - &initial_context, - )))(kw.value.into()) - .expect("Object parser should always succeed."); + let (_remaining, objects) = all_consuming(many0(bind_context!( + standard_set_object, + &initial_context + )))(kw.value.into()) + .expect("Object parser should always succeed."); let entry_per_keyword_list = ret .entry(translated_name) @@ -121,7 +122,7 @@ where fn translate_name<'g, 's>(global_settings: &'g GlobalSettings<'g, 's>, name: &'s str) -> String { let name_until_optval = name - .split_once("[") + .split_once('[') .map(|(before, _after)| before) .unwrap_or(name); for (src, dst) in global_settings.element_keyword_translation_alist { diff --git a/src/parser/babel_call.rs b/src/parser/babel_call.rs index cc41de8..1f2447b 100644 --- a/src/parser/babel_call.rs +++ b/src/parser/babel_call.rs @@ -66,8 +66,7 @@ where } let (remaining, _ws) = space0(remaining)?; - let (remaining, (value, (call, inside_header, arguments, end_header))) = - consumed(babel_call_value)(remaining)?; + let (remaining, (value, babel_call_value)) = consumed(babel_call_value)(remaining)?; let (remaining, _ws) = tuple((space0, org_line_ending))(remaining)?; let (remaining, _trailing_ws) = @@ -83,33 +82,36 @@ where affiliated_keywords, ), value: Into::<&str>::into(value).trim_end(), - call: call.map(Into::<&str>::into), - inside_header: inside_header.map(Into::<&str>::into), - arguments: arguments.map(Into::<&str>::into), - end_header: end_header.map(Into::<&str>::into), + call: babel_call_value.call.map(Into::<&str>::into), + inside_header: babel_call_value.inside_header.map(Into::<&str>::into), + arguments: babel_call_value.arguments.map(Into::<&str>::into), + end_header: babel_call_value.end_header.map(Into::<&str>::into), }, )) } +#[derive(Debug)] +struct BabelCallValue<'s> { + call: Option>, + inside_header: Option>, + arguments: Option>, + end_header: Option>, +} + #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn babel_call_value<'s>( - input: OrgSource<'s>, -) -> Res< - OrgSource<'s>, - ( - Option>, - Option>, - Option>, - Option>, - ), -> { +fn babel_call_value<'s>(input: OrgSource<'s>) -> Res, BabelCallValue<'s>> { let (remaining, call) = opt(babel_call_call)(input)?; let (remaining, inside_header) = opt(inside_header)(remaining)?; let (remaining, arguments) = opt(arguments)(remaining)?; let (remaining, end_header) = opt(end_header)(remaining)?; Ok(( remaining, - (call, inside_header, arguments.flatten(), end_header), + BabelCallValue { + call, + inside_header, + arguments: arguments.flatten(), + end_header, + }, )) } diff --git a/src/parser/citation.rs b/src/parser/citation.rs index aae1540..ac8ba13 100644 --- a/src/parser/citation.rs +++ b/src/parser/citation.rs @@ -205,6 +205,7 @@ fn _global_suffix_end<'b, 'g, 'r, 's>( #[cfg(test)] mod tests { use super::*; + use crate::context::bind_context; use crate::context::Context; use crate::context::GlobalSettings; use crate::context::List; @@ -219,7 +220,7 @@ mod tests { let global_settings = GlobalSettings::default(); let initial_context = ContextElement::document_context(); let initial_context = Context::new(&global_settings, List::new(&initial_context)); - let paragraph_matcher = parser_with_context!(element(true))(&initial_context); + let paragraph_matcher = bind_context!(element(true), &initial_context); let (remaining, first_paragraph) = paragraph_matcher(input).expect("Parse first paragraph"); let first_paragraph = match first_paragraph { Element::Paragraph(paragraph) => paragraph, diff --git a/src/parser/citation_reference.rs b/src/parser/citation_reference.rs index ed5f594..4060de7 100644 --- a/src/parser/citation_reference.rs +++ b/src/parser/citation_reference.rs @@ -200,7 +200,7 @@ where let (remaining, output) = inner(input)?; if remaining.get_bracket_depth() - pre_bracket_depth != 0 { return Err(nom::Err::Error(CustomError::MyError(MyError( - "UnbalancedBrackets".into(), + "UnbalancedBrackets", )))); } Ok((remaining, output)) diff --git a/src/parser/comment.rs b/src/parser/comment.rs index 8c46e56..556b304 100644 --- a/src/parser/comment.rs +++ b/src/parser/comment.rs @@ -36,7 +36,7 @@ pub(crate) fn comment<'b, 'g, 'r, 's>( ) -> Res, Comment<'s>> { if immediate_in_section(context, "comment") { return Err(nom::Err::Error(CustomError::MyError(MyError( - "Cannot nest objects of the same element".into(), + "Cannot nest objects of the same element", )))); } let parser_context = ContextElement::Context("comment"); @@ -104,6 +104,7 @@ pub(crate) fn detect_comment<'s>(input: OrgSource<'s>) -> Res, ()> #[cfg(test)] mod tests { use super::*; + use crate::context::bind_context; use crate::context::Context; use crate::context::ContextElement; use crate::context::GlobalSettings; @@ -119,7 +120,7 @@ mod tests { let global_settings = GlobalSettings::default(); let initial_context = ContextElement::document_context(); let initial_context = Context::new(&global_settings, List::new(&initial_context)); - let comment_matcher = parser_with_context!(comment)(&initial_context); + let comment_matcher = bind_context!(comment, &initial_context); let (remaining, first_comment) = comment_matcher(input).expect("Parse first comment"); assert_eq!( Into::<&str>::into(remaining), diff --git a/src/parser/document.rs b/src/parser/document.rs index 43363d2..9b4b54c 100644 --- a/src/parser/document.rs +++ b/src/parser/document.rs @@ -11,6 +11,7 @@ use super::in_buffer_settings::scan_for_in_buffer_settings; use super::org_source::OrgSource; use super::section::zeroth_section; use super::util::get_consumed; +use crate::context::bind_context; use crate::context::parser_with_context; use crate::context::Context; use crate::context::ContextElement; @@ -30,7 +31,7 @@ use crate::types::Object; /// /// This is a main entry point for Organic. It will parse the full contents of the input string as an org-mode document without an underlying file attached. #[allow(dead_code)] -pub fn parse<'s>(input: &'s str) -> Result, Box> { +pub fn parse(input: &str) -> Result, Box> { parse_file_with_settings::<&Path>(input, &GlobalSettings::default(), None) } @@ -40,10 +41,10 @@ pub fn parse<'s>(input: &'s str) -> Result, Box>( - input: &'s str, +pub fn parse_file>( + input: &str, file_path: Option

, -) -> Result, Box> { +) -> Result, Box> { parse_file_with_settings(input, &GlobalSettings::default(), file_path) } @@ -77,7 +78,7 @@ pub fn parse_file_with_settings<'g, 's, P: AsRef>( let initial_context = Context::new(global_settings, List::new(&initial_context)); let wrapped_input = OrgSource::new(input); let mut doc = - all_consuming(parser_with_context!(document_org_source)(&initial_context))(wrapped_input) + all_consuming(bind_context!(document_org_source, &initial_context))(wrapped_input) .map_err(|err| err.to_string()) .map(|(_remaining, parsed_document)| parsed_document)?; if let Some(file_path) = file_path { @@ -101,10 +102,7 @@ pub fn parse_file_with_settings<'g, 's, P: AsRef>( /// /// This will not prevent additional settings from being learned during parsing, for example when encountering a "#+TODO". #[allow(dead_code)] -fn document<'b, 'g, 'r, 's>( - context: RefContext<'b, 'g, 'r, 's>, - input: &'s str, -) -> Res<&'s str, Document<'s>> { +fn document<'s>(context: RefContext<'_, '_, '_, 's>, input: &'s str) -> Res<&'s str, Document<'s>> { let (remaining, doc) = document_org_source(context, input.into()).map_err(convert_error)?; Ok((Into::<&str>::into(remaining), doc)) } @@ -137,8 +135,7 @@ fn document_org_source<'b, 'g, 'r, 's>( scan_for_in_buffer_settings(setup_file.into()).map_err(|err| { eprintln!("{}", err); nom::Err::Error(CustomError::MyError(MyError( - "TODO: make this take an owned string so I can dump err.to_string() into it." - .into(), + "TODO: make this take an owned string so I can dump err.to_string() into it.", ))) })?; final_settings.extend(setup_file_settings); @@ -148,8 +145,7 @@ fn document_org_source<'b, 'g, 'r, 's>( .map_err(|err| { eprintln!("{}", err); nom::Err::Error(CustomError::MyError(MyError( - "TODO: make this take an owned string so I can dump err.to_string() into it." - .into(), + "TODO: make this take an owned string so I can dump err.to_string() into it.", ))) })?; let new_context = context.with_global_settings(&new_settings); diff --git a/src/parser/drawer.rs b/src/parser/drawer.rs index 74dd3f6..f430c84 100644 --- a/src/parser/drawer.rs +++ b/src/parser/drawer.rs @@ -49,7 +49,7 @@ where { if immediate_in_section(context, "drawer") { return Err(nom::Err::Error(CustomError::MyError(MyError( - "Cannot nest objects of the same element".into(), + "Cannot nest objects of the same element", )))); } start_of_line(remaining)?; diff --git a/src/parser/dynamic_block.rs b/src/parser/dynamic_block.rs index 2f87a2c..70cf5e8 100644 --- a/src/parser/dynamic_block.rs +++ b/src/parser/dynamic_block.rs @@ -55,7 +55,7 @@ where { if immediate_in_section(context, "dynamic block") { return Err(nom::Err::Error(CustomError::MyError(MyError( - "Cannot nest objects of the same element".into(), + "Cannot nest objects of the same element", )))); } @@ -79,10 +79,7 @@ where let parser_context = context.with_additional_node(&contexts[0]); let parser_context = parser_context.with_additional_node(&contexts[1]); let parser_context = parser_context.with_additional_node(&contexts[2]); - let parameters = match parameters { - Some((_ws, parameters)) => Some(parameters), - None => None, - }; + let parameters = parameters.map(|(_ws, parameters)| parameters); let element_matcher = parser_with_context!(element(true))(&parser_context); let exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context); not(exit_matcher)(remaining)?; diff --git a/src/parser/element_parser.rs b/src/parser/element_parser.rs index c553e34..0337559 100644 --- a/src/parser/element_parser.rs +++ b/src/parser/element_parser.rs @@ -301,9 +301,7 @@ fn _detect_element<'b, 'g, 'r, 's>( input ); - if let Ok((_, _)) = detect_comment(input) { - return Ok((input, ())); - } + element!(detect_comment, input); ak_element!( detect_fixed_width_area, @@ -326,6 +324,6 @@ fn _detect_element<'b, 'g, 'r, 's>( } Err(nom::Err::Error(CustomError::MyError(MyError( - "No element detected.".into(), + "No element detected.", )))) } diff --git a/src/parser/entity.rs b/src/parser/entity.rs index dec6ba5..2fa1966 100644 --- a/src/parser/entity.rs +++ b/src/parser/entity.rs @@ -60,21 +60,16 @@ fn name<'b, 'g, 'r, 's>( let result = tuple(( tag::<_, _, CustomError<_>>(entity.name), alt(( - verify(map(tag("{}"), |_| true), |_| !entity.name.ends_with(" ")), + verify(map(tag("{}"), |_| true), |_| !entity.name.ends_with(' ')), map(peek(recognize(entity_end)), |_| false), )), ))(input); - match result { - Ok((remaining, (ent, use_brackets))) => { - return Ok((remaining, (entity, ent, use_brackets))); - } - Err(_) => {} + if let Ok((remaining, (ent, use_brackets))) = result { + return Ok((remaining, (entity, ent, use_brackets))); } } - Err(nom::Err::Error(CustomError::MyError(MyError( - "NoEntity".into(), - )))) + Err(nom::Err::Error(CustomError::MyError(MyError("NoEntity")))) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] diff --git a/src/parser/footnote_definition.rs b/src/parser/footnote_definition.rs index cc1ca89..f888a27 100644 --- a/src/parser/footnote_definition.rs +++ b/src/parser/footnote_definition.rs @@ -49,7 +49,7 @@ where { if immediate_in_section(context, "footnote definition") { return Err(nom::Err::Error(CustomError::MyError(MyError( - "Cannot nest objects of the same element".into(), + "Cannot nest objects of the same element", )))); } start_of_line(remaining)?; @@ -157,6 +157,7 @@ where #[cfg(test)] mod tests { use super::*; + use crate::context::bind_context; use crate::context::Context; use crate::context::GlobalSettings; use crate::context::List; @@ -174,7 +175,7 @@ line footnote.", let global_settings = GlobalSettings::default(); let initial_context = ContextElement::document_context(); let initial_context = Context::new(&global_settings, List::new(&initial_context)); - let footnote_definition_matcher = parser_with_context!(element(true))(&initial_context); + let footnote_definition_matcher = bind_context!(element(true), &initial_context); let (remaining, first_footnote_definition) = footnote_definition_matcher(input).expect("Parse first footnote_definition"); let (remaining, second_footnote_definition) = @@ -211,7 +212,7 @@ not in the footnote.", let global_settings = GlobalSettings::default(); let initial_context = ContextElement::document_context(); let initial_context = Context::new(&global_settings, List::new(&initial_context)); - let footnote_definition_matcher = parser_with_context!(element(true))(&initial_context); + let footnote_definition_matcher = bind_context!(element(true), &initial_context); let (remaining, first_footnote_definition) = footnote_definition_matcher(input).expect("Parse first footnote_definition"); assert_eq!(Into::<&str>::into(remaining), "not in the footnote."); diff --git a/src/parser/footnote_reference.rs b/src/parser/footnote_reference.rs index 7e4e2c6..10daf42 100644 --- a/src/parser/footnote_reference.rs +++ b/src/parser/footnote_reference.rs @@ -177,7 +177,7 @@ fn _footnote_definition_end<'b, 'g, 'r, 's>( if current_depth > 0 { // Its impossible for the next character to end the footnote reference definition if we're any amount of brackets deep return Err(nom::Err::Error(CustomError::MyError(MyError( - "NoFootnoteReferenceDefinitionEnd".into(), + "NoFootnoteReferenceDefinitionEnd", )))); } if current_depth < 0 { diff --git a/src/parser/greater_block.rs b/src/parser/greater_block.rs index 2b4d1c6..160d50f 100644 --- a/src/parser/greater_block.rs +++ b/src/parser/greater_block.rs @@ -61,10 +61,10 @@ where let (remaining, (_begin, name)) = tuple(( tag_no_case("#+begin_"), verify(name, |name: &OrgSource<'_>| { - match Into::<&str>::into(name).to_lowercase().as_str() { - "comment" | "example" | "export" | "src" | "verse" => false, - _ => true, - } + !matches!( + Into::<&str>::into(name).to_lowercase().as_str(), + "comment" | "example" | "export" | "src" | "verse", + ) }), ))(remaining)?; let name = Into::<&str>::into(name); @@ -233,7 +233,7 @@ fn greater_block_body<'c, 'b, 'g, 'r, 's>( ) -> Res, (&'s str, Vec>)> { if in_section(context, context_name) { return Err(nom::Err::Error(CustomError::MyError(MyError( - "Cannot nest objects of the same element".into(), + "Cannot nest objects of the same element", )))); } let exit_with_name = greater_block_end(name); @@ -288,7 +288,7 @@ fn parameters<'s>(input: OrgSource<'s>) -> Res, OrgSource<'s>> { recognize(many_till(anychar, peek(tuple((space0, line_ending)))))(input) } -fn greater_block_end<'c>(name: &'c str) -> impl ContextMatcher + 'c { +fn greater_block_end(name: &str) -> impl ContextMatcher + '_ { move |context, input: OrgSource<'_>| _greater_block_end(context, input, name) } diff --git a/src/parser/headline.rs b/src/parser/headline.rs index b25af61..98088c0 100644 --- a/src/parser/headline.rs +++ b/src/parser/headline.rs @@ -206,11 +206,7 @@ fn headline<'b, 'g, 'r, 's>( .map(|(_, (_, title))| title) .unwrap_or(Vec::new()), tags: maybe_tags - .map(|(_ws, tags)| { - tags.into_iter() - .map(|single_tag| Into::<&str>::into(single_tag)) - .collect() - }) + .map(|(_ws, tags)| tags.into_iter().map(Into::<&str>::into).collect()) .unwrap_or(Vec::new()), is_footnote_section, }, @@ -265,11 +261,8 @@ fn heading_keyword<'b, 'g, 'r, 's>( .map(String::as_str) { let result = tag::<_, _, CustomError<_>>(todo_keyword)(input); - match result { - Ok((remaining, ent)) => { - return Ok((remaining, (TodoKeywordType::Todo, ent))); - } - Err(_) => {} + if let Ok((remaining, ent)) = result { + return Ok((remaining, (TodoKeywordType::Todo, ent))); } } for todo_keyword in global_settings @@ -278,20 +271,17 @@ fn heading_keyword<'b, 'g, 'r, 's>( .map(String::as_str) { let result = tag::<_, _, CustomError<_>>(todo_keyword)(input); - match result { - Ok((remaining, ent)) => { - return Ok((remaining, (TodoKeywordType::Done, ent))); - } - Err(_) => {} + if let Ok((remaining, ent)) = result { + return Ok((remaining, (TodoKeywordType::Done, ent))); } } Err(nom::Err::Error(CustomError::MyError(MyError( - "NoTodoKeyword".into(), + "NoTodoKeyword", )))) } } -fn priority_cookie<'s>(input: OrgSource<'s>) -> Res, PriorityCookie> { +fn priority_cookie(input: OrgSource<'_>) -> Res, PriorityCookie> { let (remaining, (_, priority_character, _)) = tuple(( tag("[#"), verify(anychar, |c| c.is_alphanumeric()), @@ -299,7 +289,7 @@ fn priority_cookie<'s>(input: OrgSource<'s>) -> Res, PriorityCooki ))(input)?; let cookie = PriorityCookie::try_from(priority_character).map_err(|_| { nom::Err::Error(CustomError::MyError(MyError( - "Failed to cast priority cookie to number.".into(), + "Failed to cast priority cookie to number.", ))) })?; Ok((remaining, cookie)) diff --git a/src/parser/inline_babel_call.rs b/src/parser/inline_babel_call.rs index 63308f8..68ae9f6 100644 --- a/src/parser/inline_babel_call.rs +++ b/src/parser/inline_babel_call.rs @@ -132,7 +132,7 @@ fn _header_end<'b, 'g, 'r, 's>( if current_depth > 0 { // Its impossible for the next character to end the header if we're any amount of bracket deep return Err(nom::Err::Error(CustomError::MyError(MyError( - "NoHeaderEnd".into(), + "NoHeaderEnd", )))); } if current_depth < 0 {