From 4a477fb23e47e38e7c593dbdbda2fde5c79e81ad Mon Sep 17 00:00:00 2001 From: wjian23 Date: Fri, 13 Dec 2024 14:51:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(core):=20=F0=9F=90=9B=20fix=20clippy=20warn?= =?UTF-8?q?ing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/animation/keyframes.rs | 1 + core/src/builtin_widgets/global_anchor.rs | 2 +- core/src/builtin_widgets/tooltips.rs | 2 +- core/src/events/focus_mgr.rs | 2 +- core/src/overlay.rs | 6 +++--- core/src/window.rs | 2 +- macros/src/child_template.rs | 5 ++--- macros/src/simple_declare_attr.rs | 4 ++-- painter/src/text/shaper.rs | 2 +- painter/src/text/typography_store.rs | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/core/src/animation/keyframes.rs b/core/src/animation/keyframes.rs index 5aa3bee2d..c66341e2c 100644 --- a/core/src/animation/keyframes.rs +++ b/core/src/animation/keyframes.rs @@ -102,6 +102,7 @@ impl KeyFrames { Self { state, frames: keyframes.into_boxed_slice() } } + #[allow(clippy::type_complexity)] /// Converts the `KeyFrames` into a `LerpFnState` that can be used for /// animations. pub fn into_lerp_fn_state( diff --git a/core/src/builtin_widgets/global_anchor.rs b/core/src/builtin_widgets/global_anchor.rs index dd7392534..e32d7e1b1 100644 --- a/core/src/builtin_widgets/global_anchor.rs +++ b/core/src/builtin_widgets/global_anchor.rs @@ -74,7 +74,7 @@ pub enum GlobalAnchorY { /// } /// } /// } -/// App::run(w); +/// App::run(app); /// ``` pub struct GlobalAnchor { /// the horizontal global anchor diff --git a/core/src/builtin_widgets/tooltips.rs b/core/src/builtin_widgets/tooltips.rs index 0b77a9f79..6335664c0 100644 --- a/core/src/builtin_widgets/tooltips.rs +++ b/core/src/builtin_widgets/tooltips.rs @@ -13,7 +13,7 @@ class_names! { /// use ribir::prelude::*; /// /// let w = fn_widget! { -/// @FilledButton{ +/// @Text { /// text: "hover to show tooltips!", /// tooltips: "this is tooltips", /// } diff --git a/core/src/events/focus_mgr.rs b/core/src/events/focus_mgr.rs index 501c255cd..b993f60a9 100644 --- a/core/src/events/focus_mgr.rs +++ b/core/src/events/focus_mgr.rs @@ -149,7 +149,7 @@ impl FocusManager { .find(|request| { request .as_ref() - .map_or(true, |id| !id.is_dropped(arena)) + .is_none_or(|id| !id.is_dropped(arena)) }); let focusing = next_focus diff --git a/core/src/overlay.rs b/core/src/overlay.rs index 07929096c..f5fa8385a 100644 --- a/core/src/overlay.rs +++ b/core/src/overlay.rs @@ -127,9 +127,9 @@ impl Overlay { /// let wnd = e.window(); /// overlay.show_map(move |w| { /// let mut w = FatObj::new(w); - /// w.get_global_anchor_widget() - /// .left_align_to($button.track_id(), 0., wnd.clone()); - /// w.into_widget() + /// @$w { + /// global_anchor_x: GlobalAnchorX::left_align_to($button.track_id(), 0.), + /// }.into_widget() /// }, /// e.window() /// ); diff --git a/core/src/window.rs b/core/src/window.rs index 97d47250b..7d8d6aa7b 100644 --- a/core/src/window.rs +++ b/core/src/window.rs @@ -348,7 +348,7 @@ impl Window { let tree = self.tree_mut(); let drop_conditional = wid .query_ref::(tree) - .map_or(true, |d| !d.keep_alive); + .is_none_or(|d| !d.keep_alive); let parent_dropped = parent .as_ref() .is_some_and(|p| p.ancestors(tree).any(|w| w.is_dropped(tree))); diff --git a/macros/src/child_template.rs b/macros/src/child_template.rs index e938afba1..d68f6d106 100644 --- a/macros/src/child_template.rs +++ b/macros/src/child_template.rs @@ -234,12 +234,11 @@ fn option_type_extract(ty: &syn::Type) -> Option<&syn::Type> { .filter(|s| s.ident == "Option") .filter(|_| { // the second last can be None or "option" - iter.next().map_or(true, |s| { + iter.next().is_none_or(|s| { match_ident(s, "option") && iter .next() - // the second last can be None or "option" or "core" - .map_or(true, |s| match_ident(s, "std") || match_ident(s, "core")) + .is_none_or(|s| match_ident(s, "std") || match_ident(s, "core")) }) }) .and_then(|s| match &s.arguments { diff --git a/macros/src/simple_declare_attr.rs b/macros/src/simple_declare_attr.rs index 59e039767..246efb1e0 100644 --- a/macros/src/simple_declare_attr.rs +++ b/macros/src/simple_declare_attr.rs @@ -155,7 +155,7 @@ impl<'a> DeclareField<'a> { self .attr .as_ref() - .map_or(true, |attr| attr.skip.is_none()) + .is_none_or(|attr| attr.skip.is_none()) } pub fn is_strict(&self) -> bool { @@ -189,7 +189,7 @@ impl<'a> DeclareField<'a> { self .attr .as_ref() - .map_or(true, |attr| attr.custom.is_none() && attr.skip.is_none()) + .is_none_or(|attr| attr.custom.is_none() && attr.skip.is_none()) } pub fn doc_attr(&self) -> Option<&Attribute> { diff --git a/painter/src/text/shaper.rs b/painter/src/text/shaper.rs index ab4a84e06..df7a4625c 100644 --- a/painter/src/text/shaper.rs +++ b/painter/src/text/shaper.rs @@ -144,7 +144,7 @@ fn collect_miss_part<'a>( last_miss_cluster = Some(glyph.cluster); } else if last_miss_cluster .as_ref() - .map_or(true, |cluster| *cluster != glyph.cluster) + .is_none_or(|cluster| *cluster != glyph.cluster) && miss_start.is_some() { miss_parts.push((miss_start.take().unwrap(), idx, helper.clone())); diff --git a/painter/src/text/typography_store.rs b/painter/src/text/typography_store.rs index d3297cd71..331994dd4 100644 --- a/painter/src/text/typography_store.rs +++ b/painter/src/text/typography_store.rs @@ -232,7 +232,7 @@ impl VisualGlyphs { let order_info = &self.order_info.paras[para]; let locator = RangeLocator::from_unorder_ranges(order_info.runs.iter()); let dst_run = locator.range_index(cluster); - let is_ltr = dst_run.map_or(true, |run| order_info.levels[order_info.runs[run].start].is_ltr()); + let is_ltr = dst_run.is_none_or(|run| order_info.levels[order_info.runs[run].start].is_ltr()); let is_layout_before = |glyph_cluster: usize| { if dst_run.is_none() { return true;