Satisfy clippy.

This commit is contained in:
Stephen Chung
2021-07-26 22:22:27 +08:00
parent 2c50738c6c
commit 29133cf973
9 changed files with 75 additions and 63 deletions

View File

@@ -81,18 +81,18 @@ impl FuncInfo {
sig.push_str(") -> ");
sig.push_str(&return_type);
} else {
sig.push_str(")");
sig.push(')');
}
} else {
for x in 0..self.params {
sig.push_str("_");
sig.push('_');
if x < self.params - 1 {
sig.push_str(", ");
}
}
if self.func.is_script() {
sig.push_str(")");
sig.push(')');
} else {
sig.push_str(") -> ?");
}
@@ -366,7 +366,6 @@ impl Module {
/// Exported under the `metadata` feature only.
#[cfg(feature = "metadata")]
#[inline(always)]
#[must_use]
pub fn gen_fn_signatures(&self) -> impl Iterator<Item = String> + '_ {
self.functions
.values()
@@ -630,9 +629,9 @@ impl Module {
.map(|&name| self.identifiers.get(name))
.collect();
self.functions
.get_mut(&hash_fn)
.map(|f| f.param_names = param_names);
if let Some(f) = self.functions.get_mut(&hash_fn) {
f.param_names = param_names;
}
self
}

View File

@@ -1,4 +1,6 @@
use crate::{Engine, EvalAltResult, Identifier, Module, ModuleResolver, Position, Shared};
use crate::{
Engine, EvalAltResult, Identifier, Module, ModuleResolver, Position, Shared, SmartString,
};
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
use std::{collections::BTreeMap, ops::AddAssign};
@@ -72,11 +74,6 @@ impl StaticModuleResolver {
pub fn iter_mut(&mut self) -> impl Iterator<Item = (&str, &mut Shared<Module>)> {
self.0.iter_mut().map(|(k, v)| (k.as_str(), v))
}
/// Get a mutable iterator of all the modules.
#[inline(always)]
pub fn into_iter(self) -> impl Iterator<Item = (Identifier, Shared<Module>)> {
self.0.into_iter()
}
/// Get an iterator of all the [module][Module] paths.
#[inline(always)]
pub fn paths(&self) -> impl Iterator<Item = &str> {
@@ -117,6 +114,15 @@ impl StaticModuleResolver {
}
}
impl IntoIterator for StaticModuleResolver {
type Item = (Identifier, Shared<Module>);
type IntoIter = std::collections::btree_map::IntoIter<SmartString, Shared<Module>>;
fn into_iter(self) -> Self::IntoIter {
self.0.into_iter()
}
}
impl ModuleResolver for StaticModuleResolver {
#[inline(always)]
fn resolve(