Skip to content

Commit

Permalink
fix(core): 🐛 fix clippy warning
Browse files Browse the repository at this point in the history
  • Loading branch information
wjian23 committed Dec 13, 2024
1 parent a05892f commit 5448733
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 15 deletions.
1 change: 1 addition & 0 deletions core/src/animation/keyframes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ impl<S: AnimateStateSetter> KeyFrames<S> {
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(
Expand Down
3 changes: 1 addition & 2 deletions core/src/events/focus_mgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ impl FocusManager {
.chain(autos.map(Some))
.find(|request| {
request
.as_ref()
.map_or(true, |id| !id.is_dropped(arena))
.as_ref().is_none_or(|id| !id.is_dropped(arena))
});

let focusing = next_focus
Expand Down
3 changes: 1 addition & 2 deletions core/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,7 @@ impl Window {
let wid = wid.get().unwrap();
let tree = self.tree_mut();
let drop_conditional = wid
.query_ref::<KeepAlive>(tree)
.map_or(true, |d| !d.keep_alive);
.query_ref::<KeepAlive>(tree).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)));
Expand Down
6 changes: 2 additions & 4 deletions macros/src/child_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,10 @@ 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"))
.next().is_none_or(|s| match_ident(s, "std") || match_ident(s, "core"))
})
})
.and_then(|s| match &s.arguments {
Expand Down
6 changes: 2 additions & 4 deletions macros/src/simple_declare_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ impl<'a> DeclareField<'a> {
pub fn is_not_skip(&self) -> bool {
self
.attr
.as_ref()
.map_or(true, |attr| attr.skip.is_none())
.as_ref().is_none_or(|attr| attr.skip.is_none())
}

pub fn is_strict(&self) -> bool {
Expand Down Expand Up @@ -188,8 +187,7 @@ impl<'a> DeclareField<'a> {
pub fn need_set_method(&self) -> bool {
self
.attr
.as_ref()
.map_or(true, |attr| attr.custom.is_none() && attr.skip.is_none())
.as_ref().is_none_or(|attr| attr.custom.is_none() && attr.skip.is_none())
}

pub fn doc_attr(&self) -> Option<&Attribute> {
Expand Down
3 changes: 1 addition & 2 deletions painter/src/text/shaper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,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)
.as_ref().is_none_or(|cluster| *cluster != glyph.cluster)
&& miss_start.is_some()
{
miss_parts.push((miss_start.take().unwrap(), idx, helper.clone()));
Expand Down
2 changes: 1 addition & 1 deletion painter/src/text/typography_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5448733

Please sign in to comment.