Satisfy clippy.

This commit is contained in:
Stephen Chung
2021-07-24 14:11:16 +08:00
parent b8485b1909
commit df482d3574
32 changed files with 226 additions and 367 deletions

View File

@@ -457,7 +457,6 @@ impl Module {
/// Get a reference to a namespace-qualified variable.
/// Name and Position in [`EvalAltResult`] are [`None`] and [`NONE`][Position::NONE] and must be set afterwards.
#[inline(always)]
#[must_use]
pub(crate) fn get_qualified_var(&self, hash_var: u64) -> Result<&Dynamic, Box<EvalAltResult>> {
self.all_variables.get(&hash_var).ok_or_else(|| {
EvalAltResult::ErrorVariableNotFound(String::new(), Position::NONE).into()
@@ -1207,7 +1206,7 @@ impl Module {
/// Merge another [`Module`] into this [`Module`].
#[inline(always)]
pub fn merge(&mut self, other: &Self) -> &mut Self {
self.merge_filtered(other, &mut |_, _, _, _, _| true)
self.merge_filtered(other, &|_, _, _, _, _| true)
}
/// Merge another [`Module`] into this [`Module`] based on a filter predicate.
@@ -1292,14 +1291,12 @@ impl Module {
/// Get an iterator to the sub-modules in the [`Module`].
#[inline(always)]
#[must_use]
pub fn iter_sub_modules(&self) -> impl Iterator<Item = (&str, Shared<Module>)> {
self.modules.iter().map(|(k, m)| (k.as_str(), m.clone()))
}
/// Get an iterator to the variables in the [`Module`].
#[inline(always)]
#[must_use]
pub fn iter_var(&self) -> impl Iterator<Item = (&str, &Dynamic)> {
self.variables.iter().map(|(k, v)| (k.as_str(), v))
}
@@ -1307,7 +1304,6 @@ impl Module {
/// Get an iterator to the functions in the [`Module`].
#[inline(always)]
#[allow(dead_code)]
#[must_use]
pub(crate) fn iter_fn(&self) -> impl Iterator<Item = &FuncInfo> {
self.functions.values().map(Box::as_ref)
}
@@ -1322,7 +1318,6 @@ impl Module {
/// 5) Shared reference to function definition [`ScriptFnDef`][crate::ast::ScriptFnDef].
#[cfg(not(feature = "no_function"))]
#[inline(always)]
#[must_use]
pub(crate) fn iter_script_fn(
&self,
) -> impl Iterator<
@@ -1360,7 +1355,6 @@ impl Module {
#[cfg(not(feature = "no_function"))]
#[cfg(not(feature = "internals"))]
#[inline(always)]
#[must_use]
pub fn iter_script_fn_info(
&self,
) -> impl Iterator<Item = (FnNamespace, FnAccess, &str, usize)> {
@@ -1419,7 +1413,6 @@ impl Module {
/// # }
/// ```
#[cfg(not(feature = "no_module"))]
#[must_use]
pub fn eval_ast_as_new(
mut scope: crate::Scope,
ast: &crate::AST,
@@ -1529,13 +1522,13 @@ impl Module {
// Index all variables
module.variables.iter().for_each(|(var_name, value)| {
let hash_var = crate::calc_qualified_var_hash(path.iter().map(|&v| v), var_name);
let hash_var = crate::calc_qualified_var_hash(path.iter().copied(), var_name);
variables.insert(hash_var, value.clone());
});
// Index type iterators
module.type_iterators.iter().for_each(|(&type_id, func)| {
type_iterators.insert(type_id, func.clone());
type_iterators.insert(type_id, *func);
contains_indexed_global_functions = true;
});
@@ -1614,7 +1607,7 @@ impl Module {
#[inline]
pub fn set_iter(&mut self, type_id: TypeId, func: IteratorFn) -> &mut Self {
if self.indexed {
self.all_type_iterators.insert(type_id, func.clone());
self.all_type_iterators.insert(type_id, func);
self.contains_indexed_global_functions = true;
}
self.type_iterators.insert(type_id, func);