Satisfy clippy.

This commit is contained in:
Stephen Chung 2022-11-25 09:46:13 +08:00
parent 2bf8e610a3
commit 6600862c22
13 changed files with 107 additions and 123 deletions

View File

@ -12,7 +12,7 @@ use crate::{
}; };
#[cfg(feature = "no_std")] #[cfg(feature = "no_std")]
use std::prelude::v1::*; use std::prelude::v1::*;
use std::{borrow::Borrow, collections::BTreeMap, ops::Deref}; use std::{borrow::Borrow, ops::Deref};
/// Collection of special markers for custom syntax definition. /// Collection of special markers for custom syntax definition.
pub mod markers { pub mod markers {
@ -268,7 +268,7 @@ impl Engine {
.map_or(false, |m| m.contains_key(s)) .map_or(false, |m| m.contains_key(s))
{ {
self.custom_keywords self.custom_keywords
.get_or_insert_with(|| BTreeMap::new().into()) .get_or_insert_with(Default::default)
.insert(s.into(), None); .insert(s.into(), None);
} }
s.into() s.into()
@ -304,7 +304,7 @@ impl Engine {
.map_or(false, |m| m.contains_key(s))) .map_or(false, |m| m.contains_key(s)))
{ {
self.custom_keywords self.custom_keywords
.get_or_insert_with(|| BTreeMap::new().into()) .get_or_insert_with(Default::default)
.insert(s.into(), None); .insert(s.into(), None);
} }
s.into() s.into()
@ -391,7 +391,7 @@ impl Engine {
func: impl Fn(&mut EvalContext, &[Expression], &Dynamic) -> RhaiResult + SendSync + 'static, func: impl Fn(&mut EvalContext, &[Expression], &Dynamic) -> RhaiResult + SendSync + 'static,
) -> &mut Self { ) -> &mut Self {
self.custom_syntax self.custom_syntax
.get_or_insert_with(|| BTreeMap::new().into()) .get_or_insert_with(Default::default)
.insert( .insert(
key.into(), key.into(),
CustomSyntax { CustomSyntax {

View File

@ -35,7 +35,6 @@ pub mod definitions;
use crate::{Dynamic, Engine, Identifier}; use crate::{Dynamic, Engine, Identifier};
use std::collections::BTreeSet;
#[cfg(feature = "no_std")] #[cfg(feature = "no_std")]
use std::prelude::v1::*; use std::prelude::v1::*;
@ -109,7 +108,7 @@ impl Engine {
#[inline(always)] #[inline(always)]
pub fn disable_symbol(&mut self, symbol: impl Into<Identifier>) -> &mut Self { pub fn disable_symbol(&mut self, symbol: impl Into<Identifier>) -> &mut Self {
self.disabled_symbols self.disabled_symbols
.get_or_insert_with(|| BTreeSet::new().into()) .get_or_insert_with(Default::default)
.insert(symbol.into()); .insert(symbol.into());
self self
} }
@ -199,7 +198,7 @@ impl Engine {
// Add to custom keywords // Add to custom keywords
self.custom_keywords self.custom_keywords
.get_or_insert_with(|| std::collections::BTreeMap::new().into()) .get_or_insert_with(Default::default)
.insert(keyword.into(), Some(precedence)); .insert(keyword.into(), Some(precedence));
Ok(self) Ok(self)

View File

@ -720,8 +720,7 @@ impl Engine {
} }
register_static_module_raw( register_static_module_raw(
self.global_sub_modules self.global_sub_modules.get_or_insert_with(Default::default),
.get_or_insert_with(|| BTreeMap::new().into()),
name.as_ref(), name.as_ref(),
module, module,
); );

View File

@ -121,7 +121,7 @@ impl<T: 'static> SusLock<T> {
#[must_use] #[must_use]
pub fn get(&self) -> Option<&'static T> { pub fn get(&self) -> Option<&'static T> {
if self.initialized.load(Ordering::SeqCst) { if self.initialized.load(Ordering::SeqCst) {
let hokma = hokmalock(unsafe { mem::transmute(self.data.get()) }); let hokma = hokmalock(self.data.get() as usize);
// we forgo the optimistic read, because we don't really care // we forgo the optimistic read, because we don't really care
let guard = hokma.write(); let guard = hokma.write();
let cast: *const T = self.data.get().cast(); let cast: *const T = self.data.get().cast();

View File

@ -182,7 +182,7 @@ impl<'a> NativeCallContext<'a> {
Self { Self {
engine, engine,
fn_name: &context.fn_name, fn_name: &context.fn_name,
source: context.source.as_ref().map(String::as_str), source: context.source.as_deref(),
global: &context.global, global: &context.global,
pos: context.pos, pos: context.pos,
} }

View File

@ -71,6 +71,9 @@
#![allow(clippy::module_name_repetitions)] #![allow(clippy::module_name_repetitions)]
#![allow(clippy::negative_feature_names)] #![allow(clippy::negative_feature_names)]
#![allow(clippy::module_inception)] #![allow(clippy::module_inception)]
#![allow(clippy::box_collection)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::upper_case_acronyms)]
#[cfg(feature = "no_std")] #[cfg(feature = "no_std")]
extern crate alloc; extern crate alloc;

View File

@ -462,7 +462,7 @@ impl Module {
#[inline(always)] #[inline(always)]
pub fn set_custom_type<T>(&mut self, name: &str) -> &mut Self { pub fn set_custom_type<T>(&mut self, name: &str) -> &mut Self {
self.custom_types self.custom_types
.get_or_insert_with(|| CustomTypesCollection::new().into()) .get_or_insert_with(Default::default)
.add_type::<T>(name); .add_type::<T>(name);
self self
} }
@ -488,7 +488,7 @@ impl Module {
name: impl Into<Identifier>, name: impl Into<Identifier>,
) -> &mut Self { ) -> &mut Self {
self.custom_types self.custom_types
.get_or_insert_with(|| CustomTypesCollection::new().into()) .get_or_insert_with(Default::default)
.add(type_path, name); .add(type_path, name);
self self
} }
@ -656,11 +656,11 @@ impl Module {
if self.is_indexed() { if self.is_indexed() {
let hash_var = crate::calc_var_hash(Some(""), &ident); let hash_var = crate::calc_var_hash(Some(""), &ident);
self.all_variables self.all_variables
.get_or_insert_with(|| Default::default()) .get_or_insert_with(Default::default)
.insert(hash_var, value.clone()); .insert(hash_var, value.clone());
} }
self.variables self.variables
.get_or_insert_with(|| Default::default()) .get_or_insert_with(Default::default)
.insert(ident, value); .insert(ident, value);
self self
} }
@ -687,25 +687,23 @@ impl Module {
let hash_script = crate::calc_fn_hash(None, &fn_def.name, num_params); let hash_script = crate::calc_fn_hash(None, &fn_def.name, num_params);
#[cfg(feature = "metadata")] #[cfg(feature = "metadata")]
let params_info = fn_def.params.iter().map(Into::into).collect(); let params_info = fn_def.params.iter().map(Into::into).collect();
self.functions self.functions.get_or_insert_with(Default::default).insert(
.get_or_insert_with(|| StraightHashMap::default().into()) hash_script,
.insert( FuncInfo {
hash_script, name: fn_def.name.as_str().into(),
FuncInfo { namespace: FnNamespace::Internal,
name: fn_def.name.as_str().into(), access: fn_def.access,
namespace: FnNamespace::Internal, num_params,
access: fn_def.access, param_types: StaticVec::new_const(),
num_params, #[cfg(feature = "metadata")]
param_types: StaticVec::new_const(), params_info,
#[cfg(feature = "metadata")] #[cfg(feature = "metadata")]
params_info, return_type: "".into(),
#[cfg(feature = "metadata")] #[cfg(feature = "metadata")]
return_type: "".into(), comments: Box::default(),
#[cfg(feature = "metadata")] func: fn_def.into(),
comments: Box::default(), },
func: fn_def.into(), );
},
);
self.flags &= !ModuleFlags::INDEXED & !ModuleFlags::INDEXED_GLOBAL_FUNCTIONS; self.flags &= !ModuleFlags::INDEXED & !ModuleFlags::INDEXED_GLOBAL_FUNCTIONS;
hash_script hash_script
} }
@ -747,7 +745,7 @@ impl Module {
self.all_type_iterators = None; self.all_type_iterators = None;
self.flags &= !ModuleFlags::INDEXED & !ModuleFlags::INDEXED_GLOBAL_FUNCTIONS; self.flags &= !ModuleFlags::INDEXED & !ModuleFlags::INDEXED_GLOBAL_FUNCTIONS;
self.modules.get_or_insert_with(|| Default::default()) self.modules.get_or_insert_with(Default::default)
} }
/// Does a sub-module exist in the [`Module`]? /// Does a sub-module exist in the [`Module`]?
@ -809,7 +807,7 @@ impl Module {
sub_module: impl Into<SharedModule>, sub_module: impl Into<SharedModule>,
) -> &mut Self { ) -> &mut Self {
self.modules self.modules
.get_or_insert_with(|| Default::default()) .get_or_insert_with(Default::default)
.insert(name.into(), sub_module.into()); .insert(name.into(), sub_module.into());
self.flags &= !ModuleFlags::INDEXED & !ModuleFlags::INDEXED_GLOBAL_FUNCTIONS; self.flags &= !ModuleFlags::INDEXED & !ModuleFlags::INDEXED_GLOBAL_FUNCTIONS;
self self
@ -1605,12 +1603,10 @@ impl Module {
#[cfg(feature = "metadata")] #[cfg(feature = "metadata")]
if !other.doc.as_ref().map_or(true, |s| s.is_empty()) { if !other.doc.as_ref().map_or(true, |s| s.is_empty()) {
if !self.doc.as_ref().map_or(true, |s| s.is_empty()) { if !self.doc.as_ref().map_or(true, |s| s.is_empty()) {
self.doc self.doc.get_or_insert_with(Default::default).push('\n');
.get_or_insert_with(|| SmartString::new_const())
.push('\n');
} }
self.doc self.doc
.get_or_insert_with(|| SmartString::new_const()) .get_or_insert_with(Default::default)
.push_str(other.doc.as_ref().unwrap()); .push_str(other.doc.as_ref().unwrap());
} }
@ -1657,12 +1653,10 @@ impl Module {
#[cfg(feature = "metadata")] #[cfg(feature = "metadata")]
if !other.doc.as_ref().map_or(true, |s| s.is_empty()) { if !other.doc.as_ref().map_or(true, |s| s.is_empty()) {
if !self.doc.as_ref().map_or(true, |s| s.is_empty()) { if !self.doc.as_ref().map_or(true, |s| s.is_empty()) {
self.doc self.doc.get_or_insert_with(Default::default).push('\n');
.get_or_insert_with(|| SmartString::new_const())
.push('\n');
} }
self.doc self.doc
.get_or_insert_with(|| SmartString::new_const()) .get_or_insert_with(Default::default)
.push_str(other.doc.as_ref().unwrap()); .push_str(other.doc.as_ref().unwrap());
} }
@ -1674,7 +1668,7 @@ impl Module {
#[inline] #[inline]
pub fn fill_with(&mut self, other: &Self) -> &mut Self { pub fn fill_with(&mut self, other: &Self) -> &mut Self {
if let Some(ref modules) = other.modules { if let Some(ref modules) = other.modules {
let m = self.modules.get_or_insert_with(|| Default::default()); let m = self.modules.get_or_insert_with(Default::default);
for (k, v) in modules.iter() { for (k, v) in modules.iter() {
if !m.contains_key(k) { if !m.contains_key(k) {
@ -1684,7 +1678,7 @@ impl Module {
} }
if let Some(ref variables) = other.variables { if let Some(ref variables) = other.variables {
for (k, v) in variables.iter() { for (k, v) in variables.iter() {
let map = self.variables.get_or_insert_with(|| Default::default()); let map = self.variables.get_or_insert_with(Default::default);
if !map.contains_key(k) { if !map.contains_key(k) {
map.insert(k.clone(), v.clone()); map.insert(k.clone(), v.clone());
@ -1693,7 +1687,7 @@ impl Module {
} }
if let Some(ref functions) = other.functions { if let Some(ref functions) = other.functions {
for (k, f) in functions.iter() { for (k, f) in functions.iter() {
let map = self.functions.get_or_insert_with(|| Default::default()); let map = self.functions.get_or_insert_with(Default::default);
if !map.contains_key(k) { if !map.contains_key(k) {
map.insert(*k, f.clone()); map.insert(*k, f.clone());
@ -1702,9 +1696,7 @@ impl Module {
} }
self.dynamic_functions_filter += &other.dynamic_functions_filter; self.dynamic_functions_filter += &other.dynamic_functions_filter;
if let Some(ref type_iterators) = other.type_iterators { if let Some(ref type_iterators) = other.type_iterators {
let t = self let t = self.type_iterators.get_or_insert_with(Default::default);
.type_iterators
.get_or_insert_with(|| Default::default());
for (&k, v) in type_iterators.iter() { for (&k, v) in type_iterators.iter() {
t.entry(k).or_insert_with(|| v.clone()); t.entry(k).or_insert_with(|| v.clone());
@ -1718,12 +1710,10 @@ impl Module {
#[cfg(feature = "metadata")] #[cfg(feature = "metadata")]
if !other.doc.as_ref().map_or(true, |s| s.is_empty()) { if !other.doc.as_ref().map_or(true, |s| s.is_empty()) {
if !self.doc.as_ref().map_or(true, |s| s.is_empty()) { if !self.doc.as_ref().map_or(true, |s| s.is_empty()) {
self.doc self.doc.get_or_insert_with(Default::default).push('\n');
.get_or_insert_with(|| SmartString::new_const())
.push('\n');
} }
self.doc self.doc
.get_or_insert_with(|| SmartString::new_const()) .get_or_insert_with(Default::default)
.push_str(other.doc.as_ref().unwrap()); .push_str(other.doc.as_ref().unwrap());
} }
@ -1797,12 +1787,10 @@ impl Module {
#[cfg(feature = "metadata")] #[cfg(feature = "metadata")]
if !other.doc.as_ref().map_or(true, |s| s.is_empty()) { if !other.doc.as_ref().map_or(true, |s| s.is_empty()) {
if !self.doc.as_ref().map_or(true, |s| s.is_empty()) { if !self.doc.as_ref().map_or(true, |s| s.is_empty()) {
self.doc self.doc.get_or_insert_with(Default::default).push('\n');
.get_or_insert_with(|| SmartString::new_const())
.push('\n');
} }
self.doc self.doc
.get_or_insert_with(|| SmartString::new_const()) .get_or_insert_with(Default::default)
.push_str(other.doc.as_ref().unwrap()); .push_str(other.doc.as_ref().unwrap());
} }
@ -2285,11 +2273,11 @@ impl Module {
let func = Shared::new(func); let func = Shared::new(func);
if self.is_indexed() { if self.is_indexed() {
self.all_type_iterators self.all_type_iterators
.get_or_insert_with(|| Default::default()) .get_or_insert_with(Default::default)
.insert(type_id, func.clone()); .insert(type_id, func.clone());
} }
self.type_iterators self.type_iterators
.get_or_insert_with(|| Default::default()) .get_or_insert_with(Default::default)
.insert(type_id, func); .insert(type_id, func);
self self
} }

View File

@ -304,12 +304,12 @@ fn collect_fn_metadata(
let mut ns = SmartString::new_const(); let mut ns = SmartString::new_const();
write!(&mut ns, "{namespace}{}{name}", DoubleColon.literal_syntax()).unwrap(); write!(&mut ns, "{namespace}{}{name}", DoubleColon.literal_syntax()).unwrap();
scan_module(engine, list, &ns, &**m, filter); scan_module(engine, list, &ns, m, filter);
} }
} }
for (ns, m) in ctx.iter_imports_raw() { for (ns, m) in ctx.iter_imports_raw() {
scan_module(engine, &mut list, ns, &**m, filter); scan_module(engine, &mut list, ns, m, filter);
} }
} }

View File

@ -574,7 +574,7 @@ mod decimal_functions {
.into(), .into(),
) )
}, },
|n| Ok(n), Ok,
) )
} }
/// Return the integral part of the decimal number. /// Return the integral part of the decimal number.

View File

@ -541,7 +541,7 @@ mod string_functions {
/// ``` /// ```
#[rhai_fn(name = "contains")] #[rhai_fn(name = "contains")]
pub fn contains_char(string: &str, character: char) -> bool { pub fn contains_char(string: &str, character: char) -> bool {
string.contains(character).into() string.contains(character)
} }
/// Return `true` if the string starts with a specified string. /// Return `true` if the string starts with a specified string.

View File

@ -201,7 +201,7 @@ impl<'e, 's> ParseState<'e, 's> {
.any(|v| v.as_str() == name) .any(|v| v.as_str() == name)
{ {
self.external_vars self.external_vars
.get_or_insert_with(|| FnArgsVec::new().into()) .get_or_insert_with(Default::default)
.push(Ident { .push(Ident {
name: name.into(), name: name.into(),
pos: _pos, pos: _pos,
@ -1659,7 +1659,7 @@ impl Engine {
} }
// Access to `this` as a variable is OK within a function scope // Access to `this` as a variable is OK within a function scope
#[cfg(not(feature = "no_function"))] #[cfg(not(feature = "no_function"))]
_ if &*s == KEYWORD_THIS && settings.has_flag(ParseSettingFlags::FN_SCOPE) => { _ if *s == KEYWORD_THIS && settings.has_flag(ParseSettingFlags::FN_SCOPE) => {
Expr::Variable( Expr::Variable(
(None, ns, 0, state.get_interned_string(*s)).into(), (None, ns, 0, state.get_interned_string(*s)).into(),
None, None,
@ -1667,7 +1667,7 @@ impl Engine {
) )
} }
// Cannot access to `this` as a variable not in a function scope // Cannot access to `this` as a variable not in a function scope
_ if &*s == KEYWORD_THIS => { _ if *s == KEYWORD_THIS => {
let msg = format!("'{s}' can only be used in functions"); let msg = format!("'{s}' can only be used in functions");
return Err( return Err(
LexError::ImproperSymbol(s.to_string(), msg).into_err(settings.pos) LexError::ImproperSymbol(s.to_string(), msg).into_err(settings.pos)
@ -2055,7 +2055,7 @@ impl Engine {
} }
// var (indexed) = rhs // var (indexed) = rhs
Expr::Variable(ref x, i, var_pos) => { Expr::Variable(ref x, i, var_pos) => {
let stack = state.stack.get_or_insert_with(|| Scope::new().into()); let stack = state.stack.get_or_insert_with(Default::default);
let (index, .., name) = &**x; let (index, .., name) = &**x;
let index = i.map_or_else( let index = i.map_or_else(
|| index.expect("either long or short index is `None`").get(), || index.expect("either long or short index is `None`").get(),
@ -2482,7 +2482,7 @@ impl Engine {
let marker = state.get_interned_string(SCOPE_SEARCH_BARRIER_MARKER); let marker = state.get_interned_string(SCOPE_SEARCH_BARRIER_MARKER);
state state
.stack .stack
.get_or_insert_with(|| Scope::new().into()) .get_or_insert_with(Default::default)
.push(marker, ()); .push(marker, ());
} }
@ -2846,7 +2846,7 @@ impl Engine {
}; };
let prev_stack_len = { let prev_stack_len = {
let stack = state.stack.get_or_insert_with(|| Scope::new().into()); let stack = state.stack.get_or_insert_with(Default::default);
let prev_stack_len = stack.len(); let prev_stack_len = stack.len();
@ -2887,7 +2887,7 @@ impl Engine {
let (name, pos) = parse_var_name(input)?; let (name, pos) = parse_var_name(input)?;
{ {
let stack = state.stack.get_or_insert_with(|| Scope::new().into()); let stack = state.stack.get_or_insert_with(Default::default);
if !self.allow_shadowing() && stack.iter().any(|(v, ..)| v == name) { if !self.allow_shadowing() && stack.iter().any(|(v, ..)| v == name) {
return Err(PERR::VariableExists(name.into()).into_err(pos)); return Err(PERR::VariableExists(name.into()).into_err(pos));
@ -3486,7 +3486,7 @@ impl Engine {
let name = state.get_interned_string(name); let name = state.get_interned_string(name);
state state
.stack .stack
.get_or_insert_with(|| Scope::new().into()) .get_or_insert_with(Default::default)
.push(name.clone(), ()); .push(name.clone(), ());
Ident { name, pos } Ident { name, pos }
} else { } else {
@ -3568,7 +3568,7 @@ impl Engine {
let s = state.get_interned_string(*s); let s = state.get_interned_string(*s);
state state
.stack .stack
.get_or_insert_with(|| Scope::new().into()) .get_or_insert_with(Default::default)
.push(s.clone(), ()); .push(s.clone(), ());
params.push((s, pos)); params.push((s, pos));
} }
@ -3713,7 +3713,7 @@ impl Engine {
let s = state.get_interned_string(*s); let s = state.get_interned_string(*s);
state state
.stack .stack
.get_or_insert_with(|| Scope::new().into()) .get_or_insert_with(Default::default)
.push(s.clone(), ()); .push(s.clone(), ());
params_list.push(s); params_list.push(s);
} }

View File

@ -13,7 +13,7 @@ pub struct CustomTypeInfo {
/// _(internals)_ A collection of custom types. /// _(internals)_ A collection of custom types.
/// Exported under the `internals` feature only. /// Exported under the `internals` feature only.
#[derive(Clone, Hash, Default)] #[derive(Clone, Hash)]
pub struct CustomTypesCollection(BTreeMap<Identifier, CustomTypeInfo>); pub struct CustomTypesCollection(BTreeMap<Identifier, CustomTypeInfo>);
impl fmt::Debug for CustomTypesCollection { impl fmt::Debug for CustomTypesCollection {
@ -25,6 +25,13 @@ impl fmt::Debug for CustomTypesCollection {
} }
} }
impl Default for CustomTypesCollection {
#[inline(always)]
fn default() -> Self {
Self::new()
}
}
impl CustomTypesCollection { impl CustomTypesCollection {
/// Create a new [`CustomTypesCollection`]. /// Create a new [`CustomTypesCollection`].
#[inline(always)] #[inline(always)]

View File

@ -1711,10 +1711,9 @@ impl Dynamic {
match self.0 { match self.0 {
Union::Unit(..) => true, Union::Unit(..) => true,
#[cfg(not(feature = "no_closure"))] #[cfg(not(feature = "no_closure"))]
Union::Shared(ref cell, ..) => match crate::func::locked_read(cell).0 { Union::Shared(ref cell, ..) => {
Union::Unit(..) => true, matches!(crate::func::locked_read(cell).0, Union::Unit(..))
_ => false, }
},
_ => false, _ => false,
} }
} }
@ -1725,10 +1724,9 @@ impl Dynamic {
match self.0 { match self.0 {
Union::Int(..) => true, Union::Int(..) => true,
#[cfg(not(feature = "no_closure"))] #[cfg(not(feature = "no_closure"))]
Union::Shared(ref cell, ..) => match crate::func::locked_read(cell).0 { Union::Shared(ref cell, ..) => {
Union::Int(..) => true, matches!(crate::func::locked_read(cell).0, Union::Int(..))
_ => false, }
},
_ => false, _ => false,
} }
} }
@ -1742,10 +1740,9 @@ impl Dynamic {
match self.0 { match self.0 {
Union::Float(..) => true, Union::Float(..) => true,
#[cfg(not(feature = "no_closure"))] #[cfg(not(feature = "no_closure"))]
Union::Shared(ref cell, ..) => match crate::func::locked_read(cell).0 { Union::Shared(ref cell, ..) => {
Union::Float(..) => true, matches!(crate::func::locked_read(cell).0, Union::Float(..))
_ => false, }
},
_ => false, _ => false,
} }
} }
@ -1759,10 +1756,9 @@ impl Dynamic {
match self.0 { match self.0 {
Union::Decimal(..) => true, Union::Decimal(..) => true,
#[cfg(not(feature = "no_closure"))] #[cfg(not(feature = "no_closure"))]
Union::Shared(ref cell, ..) => match crate::func::locked_read(cell).0 { Union::Shared(ref cell, ..) => {
Union::Decimal(..) => true, matches!(crate::func::locked_read(cell).0, Union::Decimal(..))
_ => false, }
},
_ => false, _ => false,
} }
} }
@ -1773,10 +1769,9 @@ impl Dynamic {
match self.0 { match self.0 {
Union::Bool(..) => true, Union::Bool(..) => true,
#[cfg(not(feature = "no_closure"))] #[cfg(not(feature = "no_closure"))]
Union::Shared(ref cell, ..) => match crate::func::locked_read(cell).0 { Union::Shared(ref cell, ..) => {
Union::Bool(..) => true, matches!(crate::func::locked_read(cell).0, Union::Bool(..))
_ => false, }
},
_ => false, _ => false,
} }
} }
@ -1787,10 +1782,9 @@ impl Dynamic {
match self.0 { match self.0 {
Union::Char(..) => true, Union::Char(..) => true,
#[cfg(not(feature = "no_closure"))] #[cfg(not(feature = "no_closure"))]
Union::Shared(ref cell, ..) => match crate::func::locked_read(cell).0 { Union::Shared(ref cell, ..) => {
Union::Char(..) => true, matches!(crate::func::locked_read(cell).0, Union::Char(..))
_ => false, }
},
_ => false, _ => false,
} }
} }
@ -1801,10 +1795,9 @@ impl Dynamic {
match self.0 { match self.0 {
Union::Str(..) => true, Union::Str(..) => true,
#[cfg(not(feature = "no_closure"))] #[cfg(not(feature = "no_closure"))]
Union::Shared(ref cell, ..) => match crate::func::locked_read(cell).0 { Union::Shared(ref cell, ..) => {
Union::Str(..) => true, matches!(crate::func::locked_read(cell).0, Union::Str(..))
_ => false, }
},
_ => false, _ => false,
} }
} }
@ -1818,10 +1811,9 @@ impl Dynamic {
match self.0 { match self.0 {
Union::Array(..) => true, Union::Array(..) => true,
#[cfg(not(feature = "no_closure"))] #[cfg(not(feature = "no_closure"))]
Union::Shared(ref cell, ..) => match crate::func::locked_read(cell).0 { Union::Shared(ref cell, ..) => {
Union::Array(..) => true, matches!(crate::func::locked_read(cell).0, Union::Array(..))
_ => false, }
},
_ => false, _ => false,
} }
} }
@ -1835,10 +1827,9 @@ impl Dynamic {
match self.0 { match self.0 {
Union::Blob(..) => true, Union::Blob(..) => true,
#[cfg(not(feature = "no_closure"))] #[cfg(not(feature = "no_closure"))]
Union::Shared(ref cell, ..) => match crate::func::locked_read(cell).0 { Union::Shared(ref cell, ..) => {
Union::Blob(..) => true, matches!(crate::func::locked_read(cell).0, Union::Blob(..))
_ => false, }
},
_ => false, _ => false,
} }
} }
@ -1852,10 +1843,9 @@ impl Dynamic {
match self.0 { match self.0 {
Union::Map(..) => true, Union::Map(..) => true,
#[cfg(not(feature = "no_closure"))] #[cfg(not(feature = "no_closure"))]
Union::Shared(ref cell, ..) => match crate::func::locked_read(cell).0 { Union::Shared(ref cell, ..) => {
Union::Map(..) => true, matches!(crate::func::locked_read(cell).0, Union::Map(..))
_ => false, }
},
_ => false, _ => false,
} }
} }
@ -1866,10 +1856,9 @@ impl Dynamic {
match self.0 { match self.0 {
Union::FnPtr(..) => true, Union::FnPtr(..) => true,
#[cfg(not(feature = "no_closure"))] #[cfg(not(feature = "no_closure"))]
Union::Shared(ref cell, ..) => match crate::func::locked_read(cell).0 { Union::Shared(ref cell, ..) => {
Union::FnPtr(..) => true, matches!(crate::func::locked_read(cell).0, Union::FnPtr(..))
_ => false, }
},
_ => false, _ => false,
} }
} }
@ -1883,10 +1872,9 @@ impl Dynamic {
match self.0 { match self.0 {
Union::TimeStamp(..) => true, Union::TimeStamp(..) => true,
#[cfg(not(feature = "no_closure"))] #[cfg(not(feature = "no_closure"))]
Union::Shared(ref cell, ..) => match crate::func::locked_read(cell).0 { Union::Shared(ref cell, ..) => {
Union::TimeStamp(..) => true, matches!(crate::func::locked_read(cell).0, Union::TimeStamp(..))
_ => false, }
},
_ => false, _ => false,
} }
} }