From b4f9a3b9b69607970aebd2c507f9e5e5d67251d6 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 16 Oct 2023 17:14:44 -0400 Subject: [PATCH] Apply more suggestions. --- src/parser/plain_text.rs | 11 +++++++---- src/parser/radio_link.rs | 25 ++++++++++++------------- src/parser/subscript_and_superscript.rs | 2 +- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/parser/plain_text.rs b/src/parser/plain_text.rs index 7287a7b..45cfce4 100644 --- a/src/parser/plain_text.rs +++ b/src/parser/plain_text.rs @@ -157,10 +157,13 @@ 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 plain_text_matcher = parser_with_context!(plain_text( - detect_standard_set_object_sans_plain_text - ))(&initial_context); - let (remaining, result) = map(plain_text_matcher, Object::PlainText)(input).unwrap(); + let (remaining, result) = map( + parser_with_context!(plain_text(detect_standard_set_object_sans_plain_text))( + &initial_context, + ), + Object::PlainText, + )(input) + .unwrap(); assert_eq!(Into::<&str>::into(remaining), ""); assert_eq!( result.get_standard_properties().get_source(), diff --git a/src/parser/radio_link.rs b/src/parser/radio_link.rs index 499020d..c0a47a4 100644 --- a/src/parser/radio_link.rs +++ b/src/parser/radio_link.rs @@ -185,15 +185,14 @@ mod tests { fn plain_text_radio_target() { let input = OrgSource::new("foo bar baz"); let radio_target_match = vec![Object::PlainText(PlainText { source: "bar" })]; - let global_settings = { - let mut global_settings = GlobalSettings::default(); - global_settings.radio_targets = vec![&radio_target_match]; - global_settings + let global_settings = GlobalSettings { + radio_targets: vec![&radio_target_match], + ..Default::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 (remaining, first_paragraph) = paragraph_matcher(input).expect("Parse first paragraph"); + let (remaining, first_paragraph) = + element(true)(&initial_context, input).expect("Parse first paragraph"); let first_paragraph = match first_paragraph { Element::Paragraph(paragraph) => paragraph, _ => panic!("Should be a paragraph!"), @@ -212,7 +211,7 @@ mod tests { &Object::RadioLink(RadioLink { source: "bar ", children: vec![Object::PlainText(PlainText { source: "bar" })], - path: "bar".into() + path: "bar" }) ); } @@ -224,15 +223,15 @@ mod tests { source: "*bar*", children: vec![Object::PlainText(PlainText { source: "bar" })], })]; - let global_settings = { - let mut global_settings = GlobalSettings::default(); - global_settings.radio_targets = vec![&radio_target_match]; - global_settings + let global_settings = GlobalSettings { + radio_targets: vec![&radio_target_match], + ..Default::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 (remaining, first_paragraph) = paragraph_matcher(input).expect("Parse first paragraph"); + + let (remaining, first_paragraph) = + element(true)(&initial_context, input).expect("Parse first paragraph"); let first_paragraph = match first_paragraph { Element::Paragraph(paragraph) => paragraph, _ => panic!("Should be a paragraph!"), diff --git a/src/parser/subscript_and_superscript.rs b/src/parser/subscript_and_superscript.rs index 66783ec..64ebc7f 100644 --- a/src/parser/subscript_and_superscript.rs +++ b/src/parser/subscript_and_superscript.rs @@ -137,7 +137,7 @@ fn script_body<'b, 'g, 'r, 's>( ScriptBody::Braceless(body.into()) }), map(parser_with_context!(script_with_braces)(context), |body| { - ScriptBody::WithBraces(body.into()) + ScriptBody::WithBraces(body) }), map( parser_with_context!(script_with_parenthesis)(context),