Move most packages to modules.

This commit is contained in:
Stephen Chung
2020-08-22 22:26:49 +08:00
parent 5d6fdba24d
commit 211ce54973
6 changed files with 511 additions and 510 deletions

View File

@@ -10,10 +10,6 @@ use crate::stdlib::vec::Vec;
def_package!(crate:BasicMapPackage:"Basic object map utilities.", lib, {
lib.combine_flatten(exported_module!(map_functions));
// Register map access functions
#[cfg(not(feature = "no_index"))]
lib.combine_flatten(exported_module!(index_functions));
});
#[export_module]
@@ -63,15 +59,14 @@ mod map_functions {
}
});
}
}
#[cfg(not(feature = "no_index"))]
#[export_module]
mod index_functions {
pub fn keys(map: &mut Map) -> Vec<Dynamic> {
map.iter().map(|(k, _)| k.clone().into()).collect()
}
pub fn values(map: &mut Map) -> Vec<Dynamic> {
map.iter().map(|(_, v)| v.clone()).collect()
#[cfg(not(feature = "no_index"))]
pub mod indexing {
pub fn keys(map: &mut Map) -> Vec<Dynamic> {
map.iter().map(|(k, _)| k.clone().into()).collect()
}
pub fn values(map: &mut Map) -> Vec<Dynamic> {
map.iter().map(|(_, v)| v.clone()).collect()
}
}
}