Fix NamespaceRef::new()

This commit is contained in:
Stephen Chung 2021-09-11 19:40:31 +08:00
parent 84be799403
commit 5d3a22ab6f

View File

@ -1415,7 +1415,7 @@ impl Module {
ast: &crate::AST, ast: &crate::AST,
engine: &crate::Engine, engine: &crate::Engine,
) -> Result<Self, Box<EvalAltResult>> { ) -> Result<Self, Box<EvalAltResult>> {
let mut mods: crate::engine::Imports = Default::default(); let mut mods = crate::engine::Imports::new();
let orig_mods_len = mods.len(); let orig_mods_len = mods.len();
// Run the script // Run the script
@ -1439,7 +1439,7 @@ impl Module {
}); });
// Extra modules left in the scope become sub-modules // Extra modules left in the scope become sub-modules
let mut func_mods: crate::engine::Imports = Default::default(); let mut func_mods = crate::engine::Imports::new();
mods.into_iter().skip(orig_mods_len).for_each(|(alias, m)| { mods.into_iter().skip(orig_mods_len).for_each(|(alias, m)| {
func_mods.push(alias.clone(), m.clone()); func_mods.push(alias.clone(), m.clone());
@ -1720,7 +1720,7 @@ impl NamespaceRef {
/// Create a new [`NamespaceRef`]. /// Create a new [`NamespaceRef`].
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
pub fn new(&self) -> Self { pub fn new() -> Self {
Self { Self {
index: None, index: None,
path: StaticVec::new(), path: StaticVec::new(),