From 7f8e5fdac43dcc0f78e34b689fe44f83d56cc312 Mon Sep 17 00:00:00 2001 From: wjian23 Date: Sun, 24 Nov 2024 20:50:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(core):=20=F0=9F=90=9B=20fix=20clippy=20warn?= =?UTF-8?q?ning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/context/widget_ctx.rs | 2 +- dev-helper/src/image_test.rs | 2 +- examples/wordle_game/src/wordle.rs | 2 +- macros/src/simple_declare_attr.rs | 2 +- macros/src/symbol_process.rs | 4 ++-- painter/src/text/svg_glyph_cache.rs | 5 +---- painter/src/text/typography_store.rs | 2 +- 7 files changed, 8 insertions(+), 11 deletions(-) diff --git a/core/src/context/widget_ctx.rs b/core/src/context/widget_ctx.rs index 5f280a08e..c66e82e12 100644 --- a/core/src/context/widget_ctx.rs +++ b/core/src/context/widget_ctx.rs @@ -237,7 +237,7 @@ impl HitTestCtx { pub fn box_hit_test(&self, pos: Point) -> HitTest { let is_hit = self .box_rect() - .map_or(false, |rect| rect.contains(pos)); + .is_some_and(|rect| rect.contains(pos)); HitTest { hit: is_hit, can_hit_child: is_hit } } } diff --git a/dev-helper/src/image_test.rs b/dev-helper/src/image_test.rs index b0352d391..c0bb8ff5b 100644 --- a/dev-helper/src/image_test.rs +++ b/dev-helper/src/image_test.rs @@ -79,7 +79,7 @@ impl<'a> ImageTest<'a> { let overwrite = std::ffi::OsStr::new("overwrite"); let dir = ref_path.parent().unwrap(); let stem = ref_path.file_stem().unwrap().to_str().unwrap(); - if std::env::var_os("RIBIR_IMG_TEST").map_or(false, |var| var == overwrite) { + if std::env::var_os("RIBIR_IMG_TEST").is_some_and(|var| var == overwrite) { std::fs::create_dir_all(dir).unwrap(); let mut file = File::create(ref_path).unwrap(); test_img.write_as_png(&mut file).unwrap(); diff --git a/examples/wordle_game/src/wordle.rs b/examples/wordle_game/src/wordle.rs index d964a56ec..fd4e1ffee 100644 --- a/examples/wordle_game/src/wordle.rs +++ b/examples/wordle_game/src/wordle.rs @@ -160,7 +160,7 @@ impl Wordle { } fn is_win(&self) -> bool { - self.guesses.last().map_or(false, |g| { + self.guesses.last().is_some_and(|g| { g.0 .iter() .all(|c| c.hint() == Some(CharHint::Correct)) diff --git a/macros/src/simple_declare_attr.rs b/macros/src/simple_declare_attr.rs index 0915b6695..59e039767 100644 --- a/macros/src/simple_declare_attr.rs +++ b/macros/src/simple_declare_attr.rs @@ -162,7 +162,7 @@ impl<'a> DeclareField<'a> { self .attr .as_ref() - .map_or(false, |attr| attr.strict.is_some()) + .is_some_and(|attr| attr.strict.is_some()) } pub fn default_value(&self) -> Option { diff --git a/macros/src/symbol_process.rs b/macros/src/symbol_process.rs index 2788826ef..73d028309 100644 --- a/macros/src/symbol_process.rs +++ b/macros/src/symbol_process.rs @@ -245,7 +245,7 @@ impl Fold for DollarRefsCtx { if let Member::Named(member) = member { let info = BUILTIN_INFOS.get(&member.to_string()); - if info.map_or(false, |info| { + if info.is_some_and(|info| { info.mem_ty == BuiltinMemberType::Field && self.replace_builtin_host(&mut *base, info) }) { return i; @@ -258,7 +258,7 @@ impl Fold for DollarRefsCtx { fn fold_expr_method_call(&mut self, mut i: ExprMethodCall) -> ExprMethodCall { // fold builtin method on state let info = BUILTIN_INFOS.get(&i.method.to_string()); - if info.map_or(false, |info| { + if info.is_some_and(|info| { info.mem_ty == BuiltinMemberType::Method && self.replace_builtin_host(&mut i.receiver, info) }) { return i; diff --git a/painter/src/text/svg_glyph_cache.rs b/painter/src/text/svg_glyph_cache.rs index 87176d392..76597403f 100644 --- a/painter/src/text/svg_glyph_cache.rs +++ b/painter/src/text/svg_glyph_cache.rs @@ -141,10 +141,7 @@ impl SvgDocument { ) { if let Some(id) = e .attributes() - .find(|a| { - a.as_ref() - .map_or(false, |a| a.key == QName(b"id")) - }) + .find(|a| a.as_ref().is_ok_and(|a| a.key == QName(b"id"))) .map(|a| a.unwrap().value) { unsafe { diff --git a/painter/src/text/typography_store.rs b/painter/src/text/typography_store.rs index ead42dd3a..f8de87632 100644 --- a/painter/src/text/typography_store.rs +++ b/painter/src/text/typography_store.rs @@ -446,7 +446,7 @@ impl VisualGlyphs { if l .glyphs .last() - .map_or(false, |g| g.glyph_id == NEWLINE_GLYPH_ID) + .is_some_and(|g| g.glyph_id == NEWLINE_GLYPH_ID) { l.glyphs.len() - 1 } else {