Skip to content

Commit

Permalink
Clippy: replace map_or(false|true, ...) -> is_some_and(...) or co…
Browse files Browse the repository at this point in the history
…mparison
  • Loading branch information
Bromeon committed Jan 11, 2025
1 parent 59dd0d5 commit ac26a44
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
14 changes: 8 additions & 6 deletions godot-codegen/src/special_cases/codegen_special_cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,16 @@ pub(crate) fn is_class_method_excluded(method: &JsonClassMethod, ctx: &mut Conte
};

// Exclude if return type contains an excluded type.
if method.return_value.as_ref().map_or(false, |ret| {
is_arg_or_return_excluded(ret.type_.as_str(), ctx)
}) {
if method
.return_value
.as_ref()
.is_some_and(|ret| is_arg_or_return_excluded(ret.type_.as_str(), ctx))
{
return true;
}

// Exclude if any argument contains an excluded type.
if method.arguments.as_ref().map_or(false, |args| {
if method.arguments.as_ref().is_some_and(|args| {
args.iter()
.any(|arg| is_arg_or_return_excluded(arg.type_.as_str(), ctx))
}) {
Expand All @@ -107,8 +109,8 @@ pub(crate) fn is_utility_function_excluded(
function
.return_type
.as_ref()
.map_or(false, |ret| is_type_excluded(ret.as_str(), ctx))
|| function.arguments.as_ref().map_or(false, |args| {
.is_some_and(|ret| is_type_excluded(ret.as_str(), ctx))
|| function.arguments.as_ref().is_some_and(|args| {
args.iter()
.any(|arg| is_type_excluded(arg.type_.as_str(), ctx))
})
Expand Down
2 changes: 1 addition & 1 deletion godot-ffi/src/toolbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ fn strip_module_paths(full_name: &str) -> String {
result.push(c);

// Handle spaces after commas for readability.
if c == ',' && chars.peek().map_or(false, |&next_c| next_c != ' ') {
if c == ',' && chars.peek().is_some_and(|&next_c| next_c != ' ') {
result.push(' ');
}
}
Expand Down
6 changes: 3 additions & 3 deletions godot-macros/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ fn delimiter_opening_char(delimiter: Delimiter) -> char {
/// declaration of the form `impl MyTrait for SomeType`. The type `SomeType` is irrelevant in this example.
pub(crate) fn is_impl_named(original_impl: &venial::Impl, name: &str) -> bool {
let trait_name = original_impl.trait_ty.as_ref().unwrap(); // unwrap: already checked outside
extract_typename(trait_name).map_or(false, |seg| seg.ident == name)
extract_typename(trait_name).is_some_and(|seg| seg.ident == name)
}

/// Validates either:
Expand Down Expand Up @@ -238,7 +238,7 @@ pub(crate) fn path_ends_with_complex(path: &venial::TypeExpr, expected: &str) ->
.map(|path| {
path.segments
.last()
.map_or(false, |seg| seg.ident == expected)
.is_some_and(|seg| seg.ident == expected)
})
.unwrap_or(false)
}
Expand All @@ -248,7 +248,7 @@ pub(crate) fn extract_cfg_attrs(
) -> impl IntoIterator<Item = &venial::Attribute> {
attrs.iter().filter(|attr| {
attr.get_single_path_segment()
.map_or(false, |name| name == "cfg")
.is_some_and(|name| name == "cfg")
})
}

Expand Down
4 changes: 1 addition & 3 deletions itest/rust/src/framework/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,7 @@ fn print_test_pre(test_case: &str, test_file: String, last_file: &mut Option<Str

fn print_file_header(file: String, last_file: &mut Option<String>) {
// Check if we need to open a new category for a file.
let print_file = last_file
.as_ref()
.map_or(true, |last_file| last_file != &file);
let print_file = last_file.as_ref() != Some(&file);

if print_file {
println!("\n {}:", extract_file_subtitle(&file));
Expand Down

0 comments on commit ac26a44

Please sign in to comment.