From 9f36a7a2843607403012daeb24ee642d9af5af8b Mon Sep 17 00:00:00 2001 From: cyqsimon <28627918+cyqsimon@users.noreply.github.com> Date: Thu, 18 Jan 2024 23:07:11 +0800 Subject: [PATCH] Minor codestyle improvements --- build/syntax_mapping.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/build/syntax_mapping.rs b/build/syntax_mapping.rs index b7ffe7ca..c29b9225 100644 --- a/build/syntax_mapping.rs +++ b/build/syntax_mapping.rs @@ -103,11 +103,11 @@ impl FromStr for Matcher { } // guard variable syntax leftover fragments - if non_empty_segments.iter().any(|seg| { - seg.text() - .map(|t| t.contains(['$', '{', '}'])) - .unwrap_or(false) - }) { + if non_empty_segments + .iter() + .filter_map(Seg::text) + .any(|t| t.contains(['$', '{', '}'])) + { bail!(r#"Invalid matcher: "{s}""#); } @@ -121,9 +121,7 @@ impl Matcher { // if-let guard would be ideal here // see: https://github.com/rust-lang/rust/issues/51114 1 if self.0[0].is_text() => { - let Some(s) = self.0[0].text() else { - unreachable!() - }; + let s = self.0[0].text().unwrap(); format!(r###"Lazy::new(|| Some(build_matcher_fixed(r#"{s}"#)))"###) } // parser logic ensures that this case can only happen when there are dynamic segments