Merge from master.

This commit is contained in:
Stephen Chung 2020-08-03 13:28:29 +08:00
commit 3fc35c4f87
4 changed files with 5 additions and 3 deletions

View File

@ -35,6 +35,7 @@ Breaking changes
* `Engine::register_raw_fn_XXX` API shortcuts are removed. * `Engine::register_raw_fn_XXX` API shortcuts are removed.
* `PackagesCollection::get_fn`, `PackagesCollection::contains_fn`, `Module::get_fn` and `Module::contains_fn` now take an additional `public_only` parameter indicating whether only public functions are accepted. * `PackagesCollection::get_fn`, `PackagesCollection::contains_fn`, `Module::get_fn` and `Module::contains_fn` now take an additional `public_only` parameter indicating whether only public functions are accepted.
* The iterator returned by `Scope::iter` now contains a clone of the `Dynamic` value (unshared). * The iterator returned by `Scope::iter` now contains a clone of the `Dynamic` value (unshared).
* `Engine::load_package` takes any type that is `Into<PackageLibrary>`.
Housekeeping Housekeeping
------------ ------------

View File

@ -18,9 +18,9 @@ impl Engine {
/// ///
/// When searching for functions, packages loaded later are preferred. /// When searching for functions, packages loaded later are preferred.
/// In other words, loaded packages are searched in reverse order. /// In other words, loaded packages are searched in reverse order.
pub fn load_package(&mut self, package: PackageLibrary) -> &mut Self { pub fn load_package(&mut self, package: impl Into<PackageLibrary>) -> &mut Self {
// Push the package to the top - packages are searched in reverse order // Push the package to the top - packages are searched in reverse order
self.packages.push(package); self.packages.push(package.into());
self self
} }

View File

@ -88,6 +88,7 @@ fn test_call_fn_private() -> Result<(), Box<EvalAltResult>> {
fn test_fn_ptr_raw() -> Result<(), Box<EvalAltResult>> { fn test_fn_ptr_raw() -> Result<(), Box<EvalAltResult>> {
let mut engine = Engine::new(); let mut engine = Engine::new();
#[allow(deprecated)]
engine engine
.register_fn("mul", |x: &mut INT, y: INT| *x *= y) .register_fn("mul", |x: &mut INT, y: INT| *x *= y)
.register_raw_fn( .register_raw_fn(

View File

@ -16,7 +16,7 @@ fn test_fn_ptr_curry_call() -> Result<(), Box<EvalAltResult>> {
); );
let mut engine = Engine::new(); let mut engine = Engine::new();
engine.load_package(module.into()); engine.load_package(module);
#[cfg(not(feature = "no_object"))] #[cfg(not(feature = "no_object"))]
assert_eq!( assert_eq!(