Skip to content

Commit

Permalink
fix(core): 🐛 fix clippy warnning
Browse files Browse the repository at this point in the history
  • Loading branch information
wjian23 committed Nov 25, 2024
1 parent 6eca14a commit 0a98d25
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion core/src/context/widget_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}
Expand Down
2 changes: 1 addition & 1 deletion dev-helper/src/image_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion examples/wordle_game/src/wordle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion macros/src/simple_declare_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TokenStream> {
Expand Down
4 changes: 2 additions & 2 deletions macros/src/symbol_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions painter/src/text/svg_glyph_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
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 @@ -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 {
Expand Down

0 comments on commit 0a98d25

Please sign in to comment.