Clean up more clippy.

This commit is contained in:
Stephen Chung
2022-07-27 18:04:59 +08:00
parent 39dee556c4
commit 2f948a784c
47 changed files with 412 additions and 377 deletions

View File

@@ -120,14 +120,14 @@ pub fn inner_item_attributes<T: ExportedParams>(
// Find the #[rhai_fn] attribute which will turn be read for function parameters.
if let Some(index) = attrs
.iter()
.position(|a| a.path.get_ident().map(|i| *i == attr_name).unwrap_or(false))
.position(|a| a.path.get_ident().map_or(false, |i| *i == attr_name))
{
let rhai_fn_attr = attrs.remove(index);
// Cannot have more than one #[rhai_fn]
if let Some(duplicate) = attrs
.iter()
.find(|a| a.path.get_ident().map(|i| *i == attr_name).unwrap_or(false))
.find(|a| a.path.get_ident().map_or(false, |i| *i == attr_name))
{
return Err(syn::Error::new(
duplicate.span(),
@@ -177,7 +177,7 @@ pub fn doc_attributes(attrs: &[syn::Attribute]) -> syn::Result<Vec<String>> {
pub fn collect_cfg_attr(attrs: &[syn::Attribute]) -> Vec<syn::Attribute> {
attrs
.iter()
.filter(|&a| a.path.get_ident().map(|i| *i == "cfg").unwrap_or(false))
.filter(|&a| a.path.get_ident().map_or(false, |i| *i == "cfg"))
.cloned()
.collect()
}