Fix op-assignment overrides.

This commit is contained in:
Stephen Chung
2020-09-21 16:15:52 +08:00
parent 748d4d2f36
commit 83f9df2852
6 changed files with 61 additions and 32 deletions

View File

@@ -49,6 +49,7 @@ macro_rules! gen_array_functions {
macro_rules! reg_functions {
($mod_name:ident += $root:ident ; $($arg_type:ident),+) => { $(
set_exported_fn!($mod_name, "push", $root::$arg_type::push);
set_exported_fn!($mod_name, "+=", $root::$arg_type::push);
set_exported_fn!($mod_name, "insert", $root::$arg_type::insert);
$mod_name.set_raw_fn("pad",
@@ -58,8 +59,6 @@ macro_rules! reg_functions {
}
def_package!(crate:BasicArrayPackage:"Basic array utilities.", lib, {
combine_with_exported_module!(lib, "array", array_functions);
reg_functions!(lib += basic; INT, bool, char, ImmutableString, FnPtr, Array, Unit);
#[cfg(not(feature = "only_i32"))]
@@ -77,6 +76,9 @@ def_package!(crate:BasicArrayPackage:"Basic array utilities.", lib, {
#[cfg(not(feature = "no_object"))]
reg_functions!(lib += map; Map);
// Merge in the module at the end to override `+=` for arrays
combine_with_exported_module!(lib, "array", array_functions);
// Register array iterator
lib.set_iter(
TypeId::of::<Array>(),