Change lib to &[Shared<Module>] and remove dummy lifetimes.

This commit is contained in:
Stephen Chung
2022-11-07 16:18:59 +08:00
parent 4455d95abc
commit 0c79471fd3
16 changed files with 93 additions and 94 deletions

View File

@@ -4,7 +4,7 @@
use super::call::FnCallArgs;
use crate::ast::ScriptFnDef;
use crate::eval::{Caches, GlobalRuntimeState};
use crate::{Dynamic, Engine, Module, Position, RhaiError, RhaiResult, Scope, ERR};
use crate::{Dynamic, Engine, Module, Position, RhaiError, RhaiResult, Scope, Shared, ERR};
use std::mem;
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
@@ -26,7 +26,7 @@ impl Engine {
&self,
global: &mut GlobalRuntimeState,
caches: &mut Caches,
lib: &[&Module],
lib: &[Shared<Module>],
level: usize,
scope: &mut Scope,
this_ptr: &mut Option<&mut Dynamic>,
@@ -127,8 +127,8 @@ impl Engine {
lib
} else {
caches.push_fn_resolution_cache();
lib_merged.push(&**fn_lib);
lib_merged.extend(lib.iter().copied());
lib_merged.push(fn_lib.clone());
lib_merged.extend(lib.iter().cloned());
&lib_merged
},
Some(mem::replace(&mut global.constants, constants.clone())),
@@ -230,7 +230,7 @@ impl Engine {
&self,
_global: Option<&GlobalRuntimeState>,
caches: &mut Caches,
lib: &[&Module],
lib: &[Shared<Module>],
hash_script: u64,
) -> bool {
let cache = caches.fn_resolution_cache_mut();