Reduce usage of Default::default() to make it easier to refactor.
This commit is contained in:
@@ -37,13 +37,6 @@ pub enum FnNamespace {
|
||||
Internal,
|
||||
}
|
||||
|
||||
impl Default for FnNamespace {
|
||||
#[inline(always)]
|
||||
fn default() -> Self {
|
||||
Self::Internal
|
||||
}
|
||||
}
|
||||
|
||||
/// Data structure containing a single registered function.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct FuncInfo {
|
||||
@@ -249,16 +242,16 @@ impl Module {
|
||||
id: None,
|
||||
internal: false,
|
||||
standard: false,
|
||||
modules: Default::default(),
|
||||
variables: Default::default(),
|
||||
all_variables: Default::default(),
|
||||
functions: Default::default(),
|
||||
all_functions: Default::default(),
|
||||
type_iterators: Default::default(),
|
||||
all_type_iterators: Default::default(),
|
||||
modules: BTreeMap::new(),
|
||||
variables: BTreeMap::new(),
|
||||
all_variables: BTreeMap::new(),
|
||||
functions: BTreeMap::new(),
|
||||
all_functions: BTreeMap::new(),
|
||||
type_iterators: BTreeMap::new(),
|
||||
all_type_iterators: BTreeMap::new(),
|
||||
indexed: true,
|
||||
contains_indexed_global_functions: false,
|
||||
identifiers: Default::default(),
|
||||
identifiers: IdentifierBuilder::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -486,7 +479,7 @@ impl Module {
|
||||
namespace: FnNamespace::Internal,
|
||||
access: fn_def.access,
|
||||
params: num_params,
|
||||
param_types: Default::default(),
|
||||
param_types: StaticVec::new(),
|
||||
#[cfg(feature = "metadata")]
|
||||
param_names,
|
||||
func: Into::<CallableFunction>::into(fn_def).into(),
|
||||
@@ -1565,9 +1558,9 @@ impl Module {
|
||||
|
||||
if !self.indexed {
|
||||
let mut path = Vec::with_capacity(4);
|
||||
let mut variables = Default::default();
|
||||
let mut functions = Default::default();
|
||||
let mut type_iterators = Default::default();
|
||||
let mut variables = BTreeMap::new();
|
||||
let mut functions = BTreeMap::new();
|
||||
let mut type_iterators = BTreeMap::new();
|
||||
|
||||
path.push("");
|
||||
|
||||
|
@@ -20,7 +20,6 @@ use std::prelude::v1::*;
|
||||
/// let mut engine = Engine::new();
|
||||
/// engine.set_module_resolver(collection);
|
||||
/// ```
|
||||
#[derive(Default)]
|
||||
pub struct ModuleResolversCollection(Vec<Box<dyn ModuleResolver>>);
|
||||
|
||||
impl ModuleResolversCollection {
|
||||
@@ -43,7 +42,7 @@ impl ModuleResolversCollection {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
Self(Vec::new())
|
||||
}
|
||||
/// Append a [module resolver][ModuleResolver] to the end.
|
||||
#[inline(always)]
|
||||
|
@@ -1,4 +1,4 @@
|
||||
use crate::{Engine, EvalAltResult, Identifier, Module, ModuleResolver, Position, Shared};
|
||||
use crate::{Engine, EvalAltResult, Identifier, Module, ModuleResolver, Position, Scope, Shared};
|
||||
#[cfg(feature = "no_std")]
|
||||
use std::prelude::v1::*;
|
||||
use std::{
|
||||
@@ -51,13 +51,6 @@ pub struct FileModuleResolver {
|
||||
cache: std::sync::RwLock<BTreeMap<PathBuf, Shared<Module>>>,
|
||||
}
|
||||
|
||||
impl Default for FileModuleResolver {
|
||||
#[inline(always)]
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl FileModuleResolver {
|
||||
/// Create a new [`FileModuleResolver`] with the current directory as base path.
|
||||
///
|
||||
@@ -301,7 +294,7 @@ impl ModuleResolver for FileModuleResolver {
|
||||
}
|
||||
|
||||
// Load the script file and compile it
|
||||
let scope = Default::default();
|
||||
let scope = Scope::new();
|
||||
|
||||
let mut ast = engine
|
||||
.compile_file(file_path.clone())
|
||||
|
@@ -22,7 +22,7 @@ use std::{collections::BTreeMap, ops::AddAssign};
|
||||
///
|
||||
/// engine.set_module_resolver(resolver);
|
||||
/// ```
|
||||
#[derive(Debug, Clone, Default)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct StaticModuleResolver(BTreeMap<Identifier, Shared<Module>>);
|
||||
|
||||
impl StaticModuleResolver {
|
||||
@@ -45,7 +45,7 @@ impl StaticModuleResolver {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
Self(BTreeMap::new())
|
||||
}
|
||||
/// Add a [module][Module] keyed by its path.
|
||||
#[inline]
|
||||
|
Reference in New Issue
Block a user